Kalman Filter to Estimate a Constant
Back

Case 1 - No Process Noise

Let's examine the use of a Kalman filter to estimate the value of a system with a gain a=1.  If there is no system noise (w) then the output of the system is a constant.  This is shown below.  The output gain (h) is set equal to 3; h=3.  The measurement noise (v) covariance (R) is set to 1; R=1.  The initial guess of the state is 1.5, and the initial estimate of the a posteriori covariance is 1. The upper left graph shows the actual state (red), the a priori estimate (red - the predictor step) and the a posteriori estimate (green - the corrected step).   The lower left graph shows the actual error between the estimates and the actual state.  The graph on the upper right shows the calculated covariances, and the graph at the lower right shows the kalman filter gain.

 a=1, h=3, Q=0, R=1;  x0=1.5, p0=1

As expected the a posteriori estimate is closer to the the exact value at each step than is the a priori estimate.  The error covariances start large, but quickly drop.  The Kalman filter gain drops as the a priori estimate is trusted more.  The Matlab code that generated this figure is here.

Case 2 - Add Some Process Noise

The next graph shows some process noise added (Q=0.01) so the state no longer stays constant.  Everything else stays the same -- I even used the same noise samples as the previous case so the comparison would be better.

 a=1, h=3, Q=0.01, R=1;  x0=1.5, p0=1

Again, the a posteriori estimate is closer to the the exact value at each step than is the a priori estimate.  The error covariances start large, but quickly drop.  The Kalman filter gain drops as the a priori estimate is trusted more, but does not drop as low as the first case (with no process noise).  This indicates that we need a larger correction at each step -- a result that shouldn't be surprising since we are adding noise to the state itself at each step.

Case 3 - Increase Process Noise

The next graph is similar to Case 2 (above); only the process noise has been increased (Q=0.1).

 a=1, h=3, Q=0.1, R=1;  x0=1.5, p0=1

Again, the a posteriori estimate is closer to the the exact value at each step than is the a priori estimate.  The error covariances start large, but quickly drop.  The Kalman filter gain drops as the a priori estimate is trusted more, but does not drop as low as the first case (with no process noise), or the second case.  This indicates that we need a larger correction at each step -- a result that shouldn't be surprising since we are adding even more noise to the measurement at each step making our a priori estimate less good.

Case 4 - Increase the Measurement Noise

The next graph is similar to Case 2 (above); only the Measurement noise has been increased (R=2).

 a=1, h=3, Q=0.01, R=2;  x0=1.5, p0=1

Again, the a posteriori estimate is closer to the the exact value at each step than is the a priori estimate.  The error covariances start large, but quickly drop.  The Kalman filter gain drops as the a priori estimate is trusted more.  It does not drop as low as the first case (with no process noise), but does drop lower than the second or case.  This means that relative to those two cases we can trust the a priori estimate more, and the measurement less, since the measurement noise is more.

The situation presented here is the very simplest case (a constant process).  A first order system is only slightly more complicated conceptually (and not at all computationally).  Such a system is considered here.

 ← Comments or Questions? Erik Cheever Engineering Department Swarthmore College