Foundations to Frontier
Tests
A. Mathematical Foundations › A10 Signal Processing

The Kalman Filter, Extended and Unscented Kalman Filters

The Kalman filter is the optimal way to combine a dynamic model with noisy measurements when everything is linear and Gaussian: predict with the model, then correct with the measurement, weighted by their uncertainties. This topic derives the predict/update equations, the Kalman gain and the Riccati recursion, explains tuning (Q and R) and consistency checks (NEES and innovations), and extends the idea to nonlinear systems with the extended Kalman filter (linearize) and the unscented Kalman filter (propagate sigma points). In the research exercise a target passing close to a range–bearing sensor exposes the EKF's overconfidence while the UKF stays consistent.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Guess, then check

You’re walking in fog with a map and a shaky compass. You guess where you are from how far you’ve walked (your model), then check against the compass (your measurement). If your step count is reliable, you mostly trust it. If the compass is good, you lean on it. The Kalman filter does exactly this, with numbers, many times a second, and it also keeps track of how unsure it is.

Kalman filter: blending a model with noisy measurements
truth (dashed) · measurements (dots) · estimate ± 2σ
RMSE: measurements 1.168 → filter 0.676 · position gain K = 0.361 · truth inside ±2σ: 95% (≈ 95% if consistent)
Each step predicts with the motion model (uncertainty grows by q) and corrects with the measurement, weighted by the gain K = P/(P + r). Too small q: the filter trusts its model, lags through the braking manoeuvre and its band becomes overconfident. Too large q or too small r: it chases the noise. Matching r to the true noise and q to the real manoeuvre level gives the lowest error and an honest band.
Why engineers care

The Kalman filter was used to navigate Apollo to the Moon. Today it fuses GNSS and IMU data in every aircraft, drone and phone, estimates spacecraft attitude and orbits, tracks targets in radar, and runs inside robot localization and SLAM. Its EKF and UKF variants handle nonlinear dynamics and sensors.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A Kalman filter combines…
  2. 2. If the measurement is very noisy, the filter trusts…
  3. 3. Which mission famously used a Kalman filter for navigation?

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Model

xk=Fxk−1+wk, w∼N(0,Q);zk=Hxk+vk, v∼N(0,R)x_k = Fx_{k-1} + w_k,\ w\sim\mathcal N(0, Q);\qquad z_k = Hx_k + v_k,\ v\sim\mathcal N(0, R)

The two steps

Predict:

x^−=Fx^,P−=FPF⊤+Q\hat x^- = F\hat x,\qquad P^- = FPF^\top + Q

Update:

S=HP−H⊤+R,K=P−H⊤S−1,x^=x^−+K(z−Hx^−),P=(I−KH)P−S = HP^-H^\top + R,\quad K = P^-H^\top S^{-1},\quad\hat x = \hat x^- + K(z - H\hat x^-),\quad P = (I - KH)P^-

Scalar intuition

With prior variance P and measurement variance R, K=P/(P+R)K = P/(P + R). The posterior variance (1−K)P=PR/(P+R)(1 - K)P = PR/(P + R) is smaller than both P and R. Fusing information always helps.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Scalar gain with P = 4, R = 4:
  2. 2. After the update the variance is…
  3. 3. The prediction step makes uncertainty…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Optimality and the steady state

For linear Gaussian systems, the KF gives the exact posterior p(xk∣z1:k)=N(x^,P)p(x_k\mid z_{1:k}) = \mathcal N(\hat x, P), the minimum-mean-square-error estimate. Without Gaussianity it’s still the best linear estimator. For time-invariant (F, H, Q, R), P converges to the solution of the discrete algebraic Riccati equation and K to a constant steady-state gain.

Tuning and consistency

  • R comes from sensor specs. Q encodes model error (manoeuvres, unmodelled forces) and is usually the tuning knob.
  • NEES e⊤P−1ee^\top P^{-1}e should average the state dimension (in simulation, where truth is known).
  • Innovations z−Hx^−z - H\hat x^- should be white with covariance S (testable in flight).
  • Use the Joseph form (I−KH)P(I−KH)⊤+KRK⊤(I - KH)P(I - KH)^\top + KRK^\top for numerical robustness.

Nonlinear systems

  • EKF: linearize ff and hh with Jacobians at the current estimate. It’s simple, but it can be biased and overconfident when nonlinearity is strong relative to the uncertainty.
  • UKF: propagate 2n+12n + 1 deterministically chosen sigma points through the true nonlinear functions, and recompute mean and covariance from them. It’s accurate to second order, needs no Jacobians, and costs about the same as an EKF (Julier and Uhlmann, 1997).
🐍 Exercise 1: a linear Kalman filter and its consistency
Implement predict and update (Joseph form) for a constant-velocity tracker. Over 50 Monte Carlo runs, check NEES ≈ 2 and position error below the measurement noise, and verify that the gain converges to the steady-state Riccati gain.
📝 Quick check (Level 2)
0/3 answered
  1. 1. A consistent filter's average NEES equals…
  2. 2. The UKF needs…
  3. 3. For time-invariant systems, the KF gain converges to…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Deriving the update (scalar, then general)

Prior N(x^−,P)\mathcal N(\hat x^-, P) and likelihood N(z;Hx,R)\mathcal N(z; Hx, R) are Gaussian. Their product is Gaussian with precision P−1+H⊤R−1HP^{-1} + H^\top R^{-1}H. The matrix inversion lemma rewrites this as P+=(I−KH)P−P^+ = (I - KH)P^- with K=P−H⊤(HP−H⊤+R)−1K = P^-H^\top(HP^-H^\top + R)^{-1}, and the mean as x^−+K(z−Hx^−)\hat x^- + K(z - H\hat x^-). ∎

Minimum variance

For any gain K, P+=(I−KH)P(I−KH)⊤+KRK⊤P^+ = (I - KH)P(I - KH)^\top + KRK^\top. Differentiating the trace with respect to K and setting it to zero gives K=PH⊤S−1K = PH^\top S^{-1}. ∎ (The Joseph form is valid for any K, which is why it’s numerically safer.)

Unscented transform

Choose X0=xˉ\mathcal X_0 = \bar x and X±i=xˉ±((n+λ)P)i\mathcal X_{\pm i} = \bar x\pm(\sqrt{(n + \lambda)P})_i, with weights w0=λ/(n+λ)w_0 = \lambda/(n + \lambda) and wi=1/(2(n+λ))w_i = 1/(2(n + \lambda)). The weighted sample mean and covariance match those of x exactly, and after a nonlinear map they’re correct to second order in the Taylor expansion (Julier and Uhlmann, 2004). ∎

Exercise 3.1: one scalar update with prior 0 ± 2 (P = 4), measurement z = 2 with R = 4

K=0.5K = 0.5, x^=1\hat x = 1, P=2P = 2. The posterior sits halfway, with half the variance.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The KF update can be derived as…
  2. 2. The Joseph-form covariance is valid for…
  3. 3. Number of sigma points for n = 6:

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

When linearization fails: EKF vs UKF

A sensor measures range accurately (±0.3 m) but bearing poorly (±25°) to a target passing within a few metres. The true posterior is a curved, banana-shaped region. The EKF linearizes the bearing at a wrong point and collapses its covariance: its median NEES is about 31 instead of about 3.4, so it’s badly overconfident, and its median final error is 9.9 m. The UKF’s sigma points see the curvature: median NEES about 5.6 and error 6.9 m. When the same tracker is used far from the sensor with modest noise, the two are nearly identical. Linearization error matters only when uncertainty is large relative to the curvature of the measurement model.

🐍 Exercise 2 (research): EKF vs UKF on close-range range–bearing tracking
Implement an EKF (with Jacobians) and a UKF (sigma points, angle wrapping) for a constant-velocity target observed by range and bearing. Over 40 Monte Carlo runs of a close pass with poor bearing accuracy, compare final position errors and NEES consistency.

Kalman filtering in AI, robotics and aerospace

  • Spaceflight: Apollo guidance computer navigation (Schmidt’s EKF at NASA Ames), multiplicative EKF for spacecraft attitude (Lefferts, Markley and Shuster, 1982), orbit determination.
  • Aircraft, drones and phones: GNSS/INS fusion (PX4 EKF2, ArduPilot EKF3); visual-inertial odometry (MSCKF).
  • Robotics: EKF-SLAM, UKF localization; factor-graph smoothers generalize the KF to whole trajectories.
  • Learning: KalmanNet and learned noise models; Kalman filtering of neural network weights (extended KF training).

References

  1. R. Kalman (1960). “A new approach to linear filtering and prediction problems.” J. Basic Engineering, 82(1).
  2. L. McGee, S. Schmidt (1985). “Discovery of the Kalman filter as a practical tool for aerospace and industry.” NASA TM-86847.
  3. S. Julier, J. Uhlmann (1997). “A new extension of the Kalman filter to nonlinear systems.” Proc. SPIE AeroSense.
  4. S. Julier, J. Uhlmann (2004). “Unscented filtering and nonlinear estimation.” Proceedings of the IEEE, 92(3).
  5. E. Lefferts, F. Markley, M. Shuster (1982). “Kalman filtering for spacecraft attitude estimation.” J. Guidance, Control, and Dynamics, 5(5).
  6. Y. Bar-Shalom, X. R. Li, T. Kirubarajan (2001). Estimation with Applications to Tracking and Navigation. Wiley.
  7. D. Simon (2006). Optimal State Estimation: Kalman, H∞, and Nonlinear Approaches. Wiley.
  8. S. Thrun, W. Burgard, D. Fox (2005). Probabilistic Robotics. MIT Press. Ch. 3.