Kalman filter
A moving object, noisy sensors, and an elegant algorithm. The Kalman filter combines a physics-based prediction with each new measurement, weighting each by its uncertainty. The result: an estimate better than either source alone. Watch prediction and correction fuse in real time.
x̂k = F x̂k−1 + Kk(zk − H F x̂k−1) K = PHᵀ(HPHᵀ + R)⁻¹
State estimation
Imagine tracking a plane on radar. Your sensor gives you a position, but it is noisy — each reading is off by some random amount. You also know the plane's velocity, so you can predict where it should be next. But your model is not perfect either: the plane might accelerate or turn. State estimation is the art of combining these two imperfect sources — the prediction from your model and the observation from your sensor — to get the best possible estimate of the true state.
The prediction-correction cycle
The Kalman filter operates in two phases on every time step. In the prediction phase, it uses the physics model (state transition matrix F) to project the current estimate forward: where should the object be now? It also grows the uncertainty, because predictions are never perfect. In the correction (or update) phase, a new measurement arrives and the filter blends it with the prediction. The blend ratio is the Kalman gain K. When the measurement is very noisy (high R), K is small and the filter trusts its prediction more. When the model is noisy (high Q), K is large and the filter trusts the measurement more. The result is always better than either source alone.
Kalman gain and convergence
The Kalman gain K is the heart of the algorithm. It answers: how much should I correct my prediction based on the new measurement? Mathematically, K = PHᵀ(HPHᵀ + R)⁻¹, where P is the estimated covariance (uncertainty), H maps state to measurement space, and R is the measurement noise covariance. As the filter runs, P converges to a steady state and K stabilizes. This is why the gold uncertainty ellipse shrinks rapidly at first and then holds steady — the filter has learned the right balance between trusting its model and trusting its sensor. The Kalman filter is provably optimal for linear systems with Gaussian noise: no other linear estimator can do better.