The Kalman filter is the closed-form solution to the Bayesian filtering equations for a linear-Gaussian state-space model. Every distribution stays Gaussian, so the filter propagates only a meanmk and covariancePk through a two-step recursion: a prediction step that pushes the state forward through the dynamics, and an update step that corrects it with the new measurement via the Kalman gainKk and the innovationvk. It runs at constant cost per time step and is the forward pass feeding both The RTS Smoother and the marginal likelihood.
Overview
Bayesian filtering computes the filtering distributionp(xk∣y1:k) — the posterior of the current state given all measurements up to now. The general recursion (Särkkä Thm. 4.1) alternates a Chapman–Kolmogorov prediction and a Bayes-rule update. For linear-Gaussian models these reduce to matrix algebra on (mk,Pk).
mk−,Pk− are the predicted (“prior”) mean and covariance before seeing yk; the superscript − marks “one step ahead, no current measurement.” mk,Pk are the updated (“posterior”) quantities afteryk.
The innovationvk=yk−Hkmk− is what the measurement tells you beyond the prediction; Sk is its covariance.
The Kalman gainKk is the optimal weight on the innovation: large when the prediction is uncertain (Pk− large) or the measurement is precise (Rk small), small otherwise.
The update always reduces covariance: Pk=Pk−−KkSkKkT⪯Pk−. An equivalent “information” form is Pk=((Pk−)−1+HkTRk−1Hk)−1.
Derivation (Särkkä §4.3): apply the Gaussian joint/conditioning lemmas (Lemmas A.1–A.2) to p(xk−1,xk∣y1:k−1) for the prediction and to p(xk,yk∣y1:k−1) for the update.
Algorithm (per time step)
given m_{k-1}, P_{k-1}: # predict m⁻ = A m_{k-1} P⁻ = A P_{k-1} Aᵀ + Q # update with y_k v = y_k − H m⁻ S = H P⁻ Hᵀ + R K = P⁻ Hᵀ S⁻¹ m_k = m⁻ + K v P_k = P⁻ − K S Kᵀ
Cost is constant per step (a few n×n / m×m products and one m×m inverse) — the key practical advantage of the recursive form over batch Bayes.
Examples
Kalman filter for the Gaussian random walk (Särkkä Ex. 4.2)
For the local-level model (A=1, H=1, scalar Q,R) the recursion collapses to scalars:
The scalar gain Kk=Pk−/(Pk−+R) interpolates between trusting the prediction (R large ⇒K→0) and trusting the measurement (R small ⇒K→1). This same filter is smoothed in The RTS Smoother.
Kalman filter for car tracking (Särkkä Ex. 4.3)
Running the 4-D constant-velocity model (see Linear-Gaussian State-Space Models) on noisy position measurements recovers the full position+velocity trajectory. In Särkkä’s simulation the position RMSE drops from 0.77 (raw measurements) to 0.43 (filter estimate) — the filter exploits the dynamics to denoise. The RTS smoother lowers it further to 0.27.