Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

python - pykalman dimensions after filter_update are not matching up

I am trying to use pykalman to apply KalmanFilter on a data. When I wrote the code for KalmanFilter on my own, it was working fine but I wanted to use the pykalman library.

The code is as follows:

Initializing code:

      self.Ve=1e-3
      self.delta=1e-4
      self.Vw=self.delta/(1-self.delta)*np.eye(2)
      self.means=np.zeros((1,2))
      self.cov=np.zeros((2,2))

      self.kf = pykalman.KalmanFilter(
          n_dim_obs=1,
          n_dim_state=2,
          transition_covariance=self.Vw,
          observation_matrices = np.matrix([0,1]),
          observation_covariance=self.Ve,
          initial_state_mean=self.means,
          initial_state_covariance=self.cov,
          )

The code to update these values:

self.means,self.cov=self.kf.filter_update(filtered_state_mean=self.means,
                                                filtered_state_covariance=self.cov,
                                                observation_matrix=self.x,
                                                observation=self.y[0])

The results that I got are as follows: Initial values of the shapes of matrices:

observation - predicted_obs_mean.shape (1, 1)
R.shape (2, 2)
Kalman Gain.shape (2, 1)
observation_matrix.shape (1, 2)
filtered_state_mean.shape (2, 1)
filtered_state_cov.shape (2, 2)
predicted_observation_covariance.shape (1, 1)
Predicted Observation Mean.shape (1, 1)

Values after one state update:

observation - predicted_obs_mean.shape (1, 2)
R.shape (2, 2)
Kalman Gain.shape (2, 1)
observation_matrix.shape (1, 2)
filtered_state_mean.shape (2, 2)
filtered_state_cov.shape (2, 2)
predicted_observation_covariance.shape (1, 1)
Predicted Observation Mean.shape (1, 2)

The state mean is changing its shape. I can't figure out why. Any help would be appreciated.

question from:https://stackoverflow.com/questions/65934550/pykalman-dimensions-after-filter-update-are-not-matching-up

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...