Python Kalman filtering and optimal estimation library. Implements Kalman filter, particle filter, Extended Kalman filter, Unscented Kalman filter, g-h (alpha-beta), least squares, H Infinity, smoothers, and more. Has companion book 'Kalman and Bayesian Filters in Python'.
Trying to following the examples provided in the documentations, but it's not really working as expected:
Using the example of filterpy.kalman.batch_filter, I get module 'filterpy.kalman' has no attribute 'F':
zs = [t + random.randn()*4 for t in range (40)]
Fs = [kf.F for t in range (40)]
Hs = [kf.H for t in range (40)]
(mu, cov, _, _) = kf.batch_filter(zs, Rs=R_list, Fs=Fs, Hs=Hs, Qs=None,
Bs=None, us=None, update_first=False)
(xs, Ps, Ks) = kf.rts_smoother(mu, cov, Fs=Fs, Qs=None)
If I use the example in batch_filter in filterpy.kalman.KalmanFilter(dim_x, dim_z, dim_u=0):
kf = KalmanFilter(dim_x=2, dim_z=1)
kf.x = np.array([2., 0.])
kf.F = np.array([[1.,1.], [0.,1.]])
kf.H = np.array([[1.,0.]])
kf.P *= 1.
kf.R = 5
from filterpy.common import Q_discrete_white_noise
kf.Q = Q_discrete_white_noise(dim=2, dt=.1, var=0.1)
zs = [t + random.randn()*4 for t in range (40)]
# Omitted Fs, since dts is not defined anywhere
# Fs = [np.array([[1., dt], [0, 1]] for dt in dts]
(mu, cov, _, _) = kf.batch_filter(zs)
(xs, Ps, Ks, _) = kf.rts_smoother(mu, cov)
This runs but gives me the following plot:
What I'm trying to do is to fit an existing curve, like so:
Trying to following the examples provided in the documentations, but it's not really working as expected:
Using the example of
filterpy.kalman.batch_filter
, I getmodule 'filterpy.kalman' has no attribute 'F'
:If I use the example in
batch_filter
infilterpy.kalman.KalmanFilter(dim_x, dim_z, dim_u=0)
:This runs but gives me the following plot:
What I'm trying to do is to fit an existing curve, like so: