Kalman Filter, Live
Recap · Reading

Recap: the extended Kalman filter

This page gathers lesson 4 in one place. A radar measures distance, a curve that no matrix H can copy, and a Gaussian pushed through it bends. Zoom in close and the curve looks straight: its slopes form the Jacobian, the stand-in for H. The Jacobian also carries uncertainty, σr² ≈ HJ P HJᵀ, which gave 5 m ± 0.71 m at (3, 4). Make two changes to the Kalman filter's update and you have the EKF. Two radars then pin down a position, and the filter tracks a robot across a yard.

Lesson 4 · slide 6Recap
ν = z − h(s⁻)    S = HJ P⁻ HJᵀ + R    K = P⁻ HJᵀ S⁻¹    s = s⁻ + Kν    P = (I − K HJ) P⁻
Key ideas
  1. A radar reads r = √(x² + y²): nonlinear, so there is no H.
  2. The Jacobian HJ = [x/r, y/r, 0, 0] is the tangent's slopes, the stand-in for H.
  3. Uncertainty passes through it like any matrix: σr² ≈ HJ P HJᵀ.
  4. EKF = the Kalman filter with ① the real h(s) in the innovation and ② HJ in place of H, recomputed every step.
  5. Two range sensors pin a 2D position; the EKF fails when the tangent is a poor fit.
  • Nonlinear sensors. A GPS reads position through a matrix. A radar reads distance, which neither adds nor flips sign like a matrix would: r(3, 0) + r(0, 4) = 7, but r(3, 4) = 5. A Gaussian pushed through that curve bends, and its mean shifts by about σ²/(2r), worst close to the sensor.
  • The Jacobian. Zoom in until the curve looks straight. The slopes ∂r/∂x = x/r and ∂r/∂y = y/r form HJ; at (3, 4) they are 0.6 and 0.8. For a radar at (a, b), use the offsets x − a and y − b. The tangent's error grows with the square of the distance from the estimate.
  • Uncertainty through a Jacobian. σr² ≈ HJ P HJᵀ = 0.36 · 0.25 + 0.64 · 0.64 = 0.4996 at (3, 4) with σx = 0.5 m and σy = 0.8 m: 5 m ± 0.71 m. Samples agree when P is small, and disagree when it is not.
  • The EKF. Predict unchanged. Update with ① ν = z − h(s⁻) and ② HJ everywhere H was. One update from (3, 4) with z = 5.3 and R = 0.25 moved the estimate to (3.0600, 4.2049), and along the line of sight it matched the lesson 1 fusion rule.
  • Range-only tracking. One radar leaves a circle; two leave two mirror points, and the prediction picks one. Stack the readings: z and h(s⁻) get 2 entries, HJ gets 2 rows. With honest R the EKF stayed about 13 m from the truth while dead reckoning drifted 87 m. Tell the filter R is too small and it zigzags (about 21 m).
  • When it fails. Big uncertainty compared with the curve's bend, a bad starting guess, weak geometry or an overconfident P. The unscented Kalman filter (UKF) pushes a few sigma points through the real h(s) instead of using a tangent.
The core trick: zoom in on the radar's curve at (3, 4) until it looks straight. The slope there, 0.6, goes into the Jacobian.
One EKF update, seen along the line to the radar: lesson 1's fusion of the predicted range (5 m) and the reading (5.3 m) gives 5.2 m.

Keep reading with the full course

Finish lesson 4 and you will be able to: track a robot from range-only radars with an EKF.

Still locked here:

  • The rest of this explanation
  • 1 more example with step-by-step solutions
  • Five extra members-only problems with worked solutions

$20 once, lifetime access. Lessons 1 and 2 stay free.

Examples

Example 1

The robot estimate is (8, 6), radar at the origin, σx = σy = 0.5 m, no correlation. Find HJ and σr.

Show solutionHide solution

r = 10, HJ = [0.8, 0.6, 0, 0]. σr² ≈ 0.64 · 0.25 + 0.36 · 0.25 = 0.25, so σr = 0.5 m.

Example 2

Radar at the origin, prediction s⁻ = (6, 8), P⁻ = I, R = 1, reading z = 10.5. Do one EKF update.

Show solutionHide solution

h(s⁻) = 10, ν = 0.5, HJ = [0.6, 0.8]. S = 1 + 1 = 2, K = (0.6, 0.8) / 2 = (0.3, 0.4).

s = (6 + 0.15, 8 + 0.2) = (6.15, 8.2), exactly 10.25 m from the radar.

Exercise Free play: move the prediction, the readings or R and watch one two-radar EKF update. Try putting the robot on the line between the radars. Edit the code and press Run.
slide_6.py Loading Python…
1
Output · Ctrl+Enter runs
Press Run to execute this slide's code. Ctrl+Enter works too.

Questions and comments

Stuck on something, or found a mistake? Ask here and I'll answer. You sign in with GitHub.

The full course

From noisy sensors to the EKF, by running it

Lessons 1 and 2 are free. Finish all four and you will be able to:

You get: all 4 lessons with Python labs · every worked example and solution · 5 extra problems per lesson · your progress tracked · Steppe, your AI tutor inside every lesson, day or night · every future update.

$20 once · lifetime access · 14-day money-back guarantee
Continue to checkout →

Already a member? Log in to the course