Expand|Select|Wrap|Line Numbers
- ##Python code
- #initialize state estimator
- kf = KalmanFilter(dim_x=1,dim_z=1)
- kf.x = numpy.array([x0]) # initial state
- kf.F = numpy.array([1.]) # state transition matrix
- kf.Q = 1000 # state noise variance,
- kf.R = 1 # measurement noise variance
- #initialize parameter estimator
- dkf = KalmanFilter(dim_x=2,dim_z=1)
- dkf.x = numpy.array([[-0.01,-0.1]]).T # initial state
- dkf.F = numpy.array([[1,0],
- [0,1]]) # state transition matrix
- dkf.Q = numpy.array([[1,0],
- [0,1]])
- dkf.R = 100 # measurement noise variance
- measurements = []
- resultsDKF = [] #dual kalman filter state estimation result
- ERRDKF = [] #estimation error
- for i in xrange(N): # N samples
- #### parameter estimator
- dkf.H = numpy.array([[kf.x,1]]) # measurement function
- y = Y[i]
- dkf.update(y,dkf.R,dkf.H)
- dkf.predict()
- #### state estimator
- kf.H = numpy.array([dkf.x[0]])
- z = Y[i]-dkf.x[1] # Y[i]-b
- kf.update(z,kf.R,kf.H)
- kf.predict()
- #### save data
- measurements.append(Y[i])
- resultsDKF.append (kf.x)
- ERRDKF.append(measurements[-1]-resultsDKF[-1])
I think the dual kalman filter doesn't really track true values of x, what's the problem? Anybody who offers advice will be much appreciated.