An object moves in the plane with nearly constant velocity (blue); we see only noisy measurements of its position (green). The latent state zn holds position and velocity, zn = Azn−1 + noise of covariance Γ, and xn = Czn + noise of covariance Σ. The Kalman filter (red) predicts each new state and corrects the prediction by the gain times the measurement error, using the data up to time n; the smoother (pink) uses all the data, so it is never less certain. Ellipses: one standard deviation.
Model (time step 1): A adds the velocity to the position; Γ = q[[⅓I, ½I], [½I, I]] is the covariance of a random acceleration of strength q over one step; C picks the position; Σ = r2I. Prior: position (0, 0) and velocity (1, 0.6), standard deviations 0.71 and 0.32. The filter uses the same q and r as the simulation. The random numbers are seeded, so a class sees the same pictures.
code/ch13_sequential_data.py (functions tracking_model, lds_sample, kalman_filter, rts_smoother, lds_em; Figure 13.22) and the checks in code/checks_ch13.py, which compare the filter and smoother with the conditionals of the joint Gaussian. lds_sample(JSRandom(seed), ...) reproduces this page's paths; preset 1 is our Figure 13.22.