Kalman filtering is the closed-form solution to the Bayesian inference problem for the linear Gaussian state-space model: a hidden Markov state that evolves linearly in time with Gaussian shocks, observed only through linear measurements corrupted by Gaussian noise. The setup is

with initial state . The inference question (what does the data tell me about the state ?) has a Gaussian answer at every because the model is linear and Gaussian throughout, and the answer can be updated sequentially in work per step rather than recomputed from scratch.

The two algorithms in this section solve different versions of the question depending on what data is available:

  • The Kalman Filter computes the posterior , the filter distribution, using only data up through the current time. This is the right tool for online estimation, real-time control, and forecasting from the current moment.
  • The Kalman Smoother computes the posterior , the smoother distribution, using the entire record (past and future). This is the right tool for retrospective analysis and missing-data interpolation.

Both algorithms are the textbook example of conjugate sequential Bayesian inference. The prior on given the past is Gaussian; the likelihood of the new observation given is Gaussian; the posterior is Gaussian by the standard Gaussian conjugacy formula. Everything else (the prediction-update split, the Kalman gain, the smoother’s backward pass) is bookkeeping that makes the recursion efficient.

Prerequisites

Contents

When to use which

Use the filter for online problems where future observations are not yet available: navigation, real-time control, online forecasting. The output at time uses only data through and arrives one step at a time as the data does. Computational cost is per step in the state dimension .

Use the smoother for offline problems where the entire data record is available and the goal is the best possible estimate at every time point: scientific reanalysis, retrospective study of recorded experiments, interpolating missing observations. The smoother runs the filter forward and then a separate backward pass that refines each estimate using all observations after time . The cost is roughly twice the filter’s.

Where the algorithm shows up

  • State-space time series. The filter computes the likelihood of an ARMA model written in state-space form, which is how statsmodels.tsa.statespace.SARIMAX evaluates the likelihood for fitting. See 2.6.2 Dynamic Linear Model for the time-series framing.
  • Robotics and control. State estimation for vehicles and robots, fusing IMU, GPS, and other sensors, is a canonical Kalman application. The Apollo and Artemis missions use extended versions of the algorithm.
  • Bayesian regression with drifting coefficients. Putting a state-space prior on regression coefficients that evolve as a random walk turns ordinary regression into a Kalman filter on the coefficient vector: the basis for recursive least squares and time-varying regression in econometrics.
  • Gaussian process regression in time. When a GP uses a kernel that admits a state-space representation (Matérn family with half-integer smoothness), GP regression on a 1-D time index can be done in via the Kalman filter rather than via direct conditioning.

See Also