I have a trajectory of an object in a 2D space (a surface). The trajectory is given as a sequence of
(x,y) coordinates. I know that my measurements are noisy and sometimes I have obvious outliers. So, I want to filter my observations.
As far as I understood Kalman filter, it does exactly what I need. So, I try to use it. I found a python implementation here. And this is the example that the documentation provides:
from pykalman import KalmanFilter import numpy as np kf = KalmanFilter(transition_matrices = [[1, 1], [0, 1]], observation_matrices = [[0.1, 0.5], [-0.3, 0.0]]) measurements = np.asarray([[1,0], [0,0], [0,1]]) # 3 observations kf = kf.em(measurements, n_iter=5) (filtered_state_means, filtered_state_covariances) = kf.filter(measurements) (smoothed_state_means, smoothed_state_covariances) = kf.smooth(measurements)
I have some troubles with interpretation of input and output. I guess that
measurements is exactly what my measurements are (coordinates). Although I am a bit confused because measurements in the example are integers.
I also need to provide some
observation_matrices. What values should I put there? What do these matrices mean?
Finally, where can I find my output? Should it be
smoothed_state_means. These arrays have correct shapes
(2, n_observations). However, the values in these array are too far from the original coordinates.
So, how to use this Kalman filter?