简体   繁体   中英

state estimation by Dual Kalman Filter

I want to estimate a variable x, and the observable variable y can be obtained from sensors. These two variables has an approximately linear relationship,ie, y=k*x + b, but k and b are difficult to get, so I use two kalman filters, one for state (x) estimation, another for parameter (k,b) estimation, which actually combines the dual kalman filter. The general scheme and code in Python is as follows,

the general scheme

##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])

the results are also followed:

setting of initial state much away from true value

It seems that the predicted state varies with the true value, but there still is a big gap between predicted and true value.

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.

Part of the power of the Kalman filter is that it develops and propagates correlations between the error's in the states. By separating the problem into two filters, you preclude either filter from figuring out that there's an error it doesn't know about, because it's not modeled. In the specific case you've described, where:

y=k*x + b

with k & b both unknown you should make x, k & b states of a single Kalman filter. Over time with enough observations of a varying x (ie y measurements from different x values), the filter can observe k and b because of the correlation in the x, k, and b states carried in the covariance matrix. With the 'x' filter separated from the 'k' and 'b' filter, it can remain offset forever, as in your result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM