Kalman Filters
A Kalman filter estimates a hidden state over time by alternating prediction and correction. It is the recursive inference engine for many state-space models: the model predicts how the latent state should evolve, observes a noisy measurement, then blends the two in proportion to their relative uncertainty. It is exactly the Bayesian filtering recursion for the special case where everything is linear and Gaussian, and in that case it is optimal in the mean-squared-error sense.
Linear Gaussian State-Space Model
The filter assumes a latent state that evolves linearly and is observed through a linear measurement:
where is the transition matrix, the observation matrix, is process noise, and is measurement noise. The state is summarized by a mean and covariance ; the filter propagates both.
The Predict–Update Cycle
Each step runs two phases. Prediction pushes the state through the dynamics and grows uncertainty by the process noise. Update pulls the state toward the new measurement by an amount set by the Kalman gain.
flowchart TD Init[Initial state estimate and covariance] --> Predict[Predict step: project state forward and grow covariance by process noise] Predict --> Innovation[Compute innovation from the new measurement] Innovation --> Gain[Compute Kalman gain from relative uncertainty] Gain --> Update[Update step: correct state and shrink covariance] Update --> Predict Update --> Forecast[Predictive distribution for forecasting]
| Phase | Computes | Effect on uncertainty |
|---|---|---|
| Predict | prior mean and covariance | grows by process noise |
| Update | posterior mean and covariance | shrinks by the measurement |
Predict:
Update. Form the innovation (measurement residual) and the Kalman gain:
then correct the state and covariance:
Why the Gain Is the Whole Story
The gain interpolates between trusting the model and trusting the measurement. If measurement noise is large, is small and the filter mostly keeps its prediction. If state uncertainty is large, approaches the value that snaps the estimate onto the observation. This adaptive weighting is what makes Kalman filtering useful for online forecasting, object tracking, sensor smoothing, and any model where prediction intervals should reflect evolving state uncertainty.
Worked Scalar Example
Track a scalar position with , , process noise , measurement noise , starting from , . A measurement arrives.
- Predict: , and .
- Innovation: .
- Gain: .
- Update: , and .
The estimate moves about halfway to the observation because the prior and the measurement carry almost equal uncertainty, and the posterior variance drops from to .
Filtering, Prediction, and Smoothing
- Filtering gives , the best estimate of the current state from data up to now.
- Prediction gives and its covariance, the one-step or multi-step forecast distribution before observations arrive. This is the object used for live forecasting.
- Smoothing (for example, the Rauch–Tung–Striebel recursion) revisits earlier states using later observations. It is more accurate for retrospective analysis but is not causal, so it cannot be used to generate real-time forecasts.
When Linearity Breaks
Real systems are often nonlinear. Three standard extensions relax the linear-Gaussian assumption:
| Method | Idea | Trade-off |
|---|---|---|
| Extended Kalman Filter | linearize and with Jacobians around the estimate | cheap, but biased under strong curvature |
| Unscented Kalman Filter | propagate a set of sigma points through the true nonlinearity | more accurate, no Jacobians, slightly costlier |
| Particle Filter | represent the posterior with weighted samples | handles nonlinear, non-Gaussian; expensive |
The Kalman filter also generalizes several simpler methods: a suitable state-space form makes exponential smoothing and recursive least squares special cases of the same recursion.
Practical Guidance
- The filter is only as good as , , , and . A mis-specified or makes the state sluggish or jittery; and are often tuned by maximizing the innovation likelihood.
- Monitor innovations like any other forecast monitoring signal. Under a correct model they are zero-mean and white with covariance ; persistent bias or autocorrelation flags model drift, especially after sensor changes or regime shifts.
- For numerical stability, use the Joseph form of the covariance update or a square-root filter, which keep symmetric and positive semi-definite.
- When the regime changes, adaptive noise estimates or online retraining may be needed.
Connections
- State-Space Models provide the structure the filter operates on.
- Exponential Smoothing is a special case recoverable from a local-level state-space model.
- Prediction Intervals can be built directly from the filter’s predictive covariance.
References
- Kalman, 1960, A New Approach to Linear Filtering and Prediction Problems
- Särkkä, 2013, Bayesian Filtering and Smoothing
- statsmodels state-space documentation
Nav