Kalman Filter

The Kalman filter is the closed-form recursive Bayesian filter for the linear Gaussian state-space model. Given a hidden state that evolves as with , observed through with , the filter produces the Gaussian posterior at every time step using only the previous step’s posterior and the new observation.

Each step splits into two operations. The prediction step propagates the previous posterior forward through the dynamics, producing the one-step-ahead prior on the state before seeing :

The mean is updated by the deterministic dynamics; the covariance is propagated by the same dynamics and inflated by the process noise . Uncertainty about the state grows during prediction because the random shock adds variance.

The update step then conditions on the new observation , applying the standard Gaussian conditioning identity to combine the prior with the likelihood :

where the Kalman gain is

The gain is the Bayesian-conjugacy weight that determines how much the new observation shifts the prior mean. The quantity is the innovation: the part of the observation that the prediction did not anticipate.

The whole recursion runs forward in , starting from the initial state . At every step the cost is in the state dimension (dominated by the matrix inverse inside the Kalman gain), independent of how much past data has accumulated.

Linear-Gaussian Assumption linear dynamics and observations with Gaussian noise. When either assumption breaks, exact inference is no longer Gaussian and approximations are needed: the Extended Kalman Filter (EKF) linearizes non-linear dynamics around the current estimate, the Unscented Kalman Filter (UKF) propagates a small set of sample points through the non-linearity, and the particle filter drops Gaussianity entirely in favor of a Monte Carlo posterior. All three reduce to the standard Kalman filter when the model is exactly linear-Gaussian.

The closed-form recursion only applies to

Intuition

The Kalman filter is conjugate Bayesian inference applied one observation at a time. The prior at the start of step is the posterior from step propagated forward through the dynamics; the likelihood for step is the Gaussian density of the new observation given the state; and the posterior is the Gaussian conjugate-update of those two ingredients. The remarkable fact about the linear-Gaussian setting is that the posterior is also Gaussian, so the same machinery applies at the next step without any approximation. The filter is therefore the time-series analogue of Bayesian linear regression, with the static parameter replaced by a state that evolves over time.

The two-step prediction-update structure makes the Bayesian story explicit. The prediction step does not look at at all; it just asks “where would I expect the state to be at time given everything I knew at time ?”, propagating both the mean and the uncertainty through the dynamics. The update step then absorbs the new observation, shifting the prior mean toward what suggests by an amount controlled by the Kalman gain . The gain is the relative-trust ratio between the prediction and the measurement: if the measurement noise is large compared to the predicted state covariance , the gain is small and the prior is barely moved; if the measurement noise is small (a precise sensor) the gain is close to (or its right pseudo-inverse) and the prior is replaced by the measurement. This automatic re-weighting between prior knowledge and new evidence is the Bayesian update made operational.

Properties

(Two-Step Recursion) Each filter step is a prediction propagating the posterior forward, followed by an update conditioning on the new observation.

The prediction step uses only the dynamics and the previous posterior; it produces the prior at time . The update step uses only the observation model and the new ; it produces the posterior . Splitting the recursion this way is what makes it computationally cheap (no need to revisit past data) and conceptually clean (prior is propagated then reconditioned).

(Kalman Gain as Trust Ratio) is the optimal weight between the prediction and the new observation.

The gain has the form (prior covariance × measurement Jacobian) divided by (predicted measurement covariance + noise covariance). Two limiting cases make the meaning concrete: in the high-noise limit , the gain and the update degenerates to , so a worthless measurement does not move the prior. In the low-noise limit with invertible, the gain and the update becomes , so a perfect measurement overrides the prior entirely. Between those extremes the gain is the optimal Bayesian compromise.

(Innovation) The residual is the new information in .

The innovation is what the prediction got wrong: the part of the observation that the dynamics did not already explain. Two consequences flow from this. First, the update equation adjusts the prior by the Kalman-weighted innovation, so the size of the correction is set by how surprising the observation was. Second, when the model is correctly specified, the innovation sequence is white noise (mean zero, uncorrelated across time) with covariance . This innovation whiteness is the standard model diagnostic: non-white innovations indicate that the dynamics, the observation matrix, or the noise covariances are misspecified.

(Likelihood Computation) The filter produces the model likelihood as a by-product.

Each innovation has a known Gaussian density under the model, so the joint likelihood of the observed data factorizes into a product of one-step-ahead predictive densities,

The Kalman filter computes every term in this sum in passing, so likelihood evaluation costs no more than running the filter. This is how statsmodels evaluates ARIMA likelihoods (cast as state-space models) and how unknown parameters are estimated by maximum likelihood on top of the filter.

(Cost is Per Step) The filter runs in time independent of how much data has accumulated.

The dominant cost at each step is the inverse of the matrix inside the Kalman gain, where is the observation dimension; the rest of the operations are matrix products at in the state dimension. Crucially, the recursion does not revisit any past observation: all the history is summarized by the current pair. So the total cost of running the filter on a length- record is , not or , which is what makes it practical for online use on long records.

(Steady State) For a time-invariant model, the covariance converges to a fixed point as grows.

When do not depend on and the system is stable, the recursion with converges to the unique solution of the discrete algebraic Riccati equation. In steady state the gain also becomes constant, so the filter reduces to a fixed linear filter on the innovations, useful for analytical work and for fast online implementations that precompute the steady-state gain.

(Missing Data is Free) Skip the update step when no observation is available.

If is missing at time , the filter performs only the prediction step and carries the prior forward. The covariance is larger than it would be after an update; the filter is honest that no new information arrived. When the next observation comes in at time , the prediction step is repeated times to bring the prior up to date, then the update step uses as usual. This handles arbitrary patterns of missing data without any special-purpose code.

Examples

Derivation

The Kalman update is a direct application of the Gaussian conditioning identity. At time the prior is from the prediction step, and the observation given the state is . The joint distribution of given the past is Gaussian with mean and covariance

Applying the Gaussian conditioning formula (see 6.2 Multivariate Gaussian Distribution) for given produces

with , exactly the update equation. The Kalman gain is therefore not a separate concept to memorize but the cross-covariance-times-inverse-marginal-covariance term of the standard conditioning formula, specialized to this model.

The prediction step follows the same logic propagated through the dynamics. If and with independent of the past, then is the linear-transformation-plus-noise of a Gaussian, which is again Gaussian with mean and covariance . So the prediction step is also nothing but the standard rule for the distribution of a linear function of a Gaussian random variable.

The whole recursion is therefore one Gaussian conjugacy step (prediction) followed by one Gaussian conditioning step (update), repeated forever. The Kalman gain and the prediction-update structure are presentation choices; the math underneath is the same conjugate-update story as Normal-Normal Bayesian inference, extended to handle a state that evolves between observations.

See Also