x⁻ = F x + B u P⁻ = F P Fᵀ + Q K = P⁻Hᵀ(H P⁻ Hᵀ + R)⁻¹ x = x⁻ + K(z − H x⁻) P = (I − K H) P⁻
Key ideas
- Covariance is the average product of deviations. Its sign is the tilt of the cloud.
- The covariance matrix: variances on the diagonal, covariances off it, symmetric. Its picture is the 2σ ellipse.
- y = A x + b moves the covariance to A P Aᵀ. The shift b never changes it.
- A state-space model is xₖ₊₁ = F xₖ + B uₖ and zₖ = H xₖ. The physics lives in F, the inputs in B, the sensors in H.
- The matrix filter is the 1D filter with matrices, and a position sensor also corrects velocity.
- Correlation and covariance. Ice cream rises with temperature, hot chocolate falls, coffee does not care. cov(x, y) = average of (x − μₓ)(y − μᵧ): positive, negative or about zero.
- The covariance matrix. P holds σₓ², σᵧ² and σₓᵧ. The correlation ρ = σₓᵧ / (σₓσᵧ) lies between −1 and 1. The 2σ ellipse is wide where the variance is big and tilts with the covariance.
- Transforming covariance. The scalar rule a²σ² becomes A P Aᵀ. One tick of motion turns P with 4 and 1 on the diagonal into F P Fᵀ = 5111: motion links position and velocity.
- State space. The state is what you need to predict the future: position and velocity. F = 1Δt01 moves it, friction and a motor push change the velocity row, H = 10 is a GPS.
- The matrix Kalman filter. Predict with F and F P Fᵀ + Q. Correct with the gain K = P⁻Hᵀ(H P⁻ Hᵀ + R)⁻¹ and the innovation z − H x⁻. The worked cycle took the position variance from 6 to 2.4 and left an off-diagonal of 0.4.
- Rocket tracking. State (x, y, vₓ, vᵧ), F as two constant-velocity blocks, H keeps the positions. Big q follows the GPS, small q smooths it, too small misses the bend.
Free play in the lab
An optional goal for the lab below: see how close you can get the printed velocity estimate to the true speed (2 m/s) after 40 s. Try a smaller q, then a bigger R, then change the true speed, and watch how the ±2σ band reacts.
Next lesson: the extended Kalman filter
Keep reading with the full course
Finish lesson 3 and you will be able to: track position and velocity in 2D with the matrix Kalman filter.
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
P = 16−4−44. Find σₓ, σᵧ and ρ, and say which way the ellipse tilts.
Show solutionHide solution
σₓ = 4, σᵧ = 2, ρ = −4 / (4 · 2) = −0.5. Wider than tall, tilting down to the right.
Example 2
P = 1001, F = 1101, Q = 0. Find P⁻. Then, with H = 10 and R = 2, find K.
Show solutionHide solution
P⁻ = F Fᵀ = 2111.
S = 2 + 2 = 4, K = (2, 1) / 4 = (0.5, 0.25).

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