Kalman Filter Redux

by JS

I discovered some errors in my Kalman filter code. For those keeping track at home I was using the true state to update the filter each iteration, and I used the wrong predicted covariance in one part of the correction step. I’ve updated my code here.

Incidentally, I discovered the error when testing whether the estimated states were a better estimate for the true states than either the predictors (pre-correction) or observations alone. For the original code, this was not true. In particular, the predictors were more accurate than the corrected estimate. Since Kalman filters are supposed to be optimal, and the corrected estimate is supposed to be better than the prediction alone, I realized something was amiss.

The key lesson here is that, though the pictures my code produced looked convincing, the numerical analysis revealed some fairly major errors. Mathematicians have many examples of why pictures aren’t proofs. Even for empirical studies (including implementations of provably-optimal estimators), pictures cannot replace proper tests.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Tumblr
  • Twitter