Kalman Filter, Live
Recap · Reading

Lesson 1 recap: noise, the bell curve and data fusion

Lesson 1 in one page. Every sensor reads the truth plus noise, and two numbers describe that noise: the mean and the variance. Noise piles up into a bell curve, and a small variance means a tall, narrow bell and a sensor you can trust. Two sensors fuse into one estimate with the gain K, and the result is more certain than either. That fusion rule is the seed of the Kalman filter.

Lesson 1 · slide 6Recap
reading = truth + noise    N(μ, σ²)    K = σ₁² / (σ₁² + σ₂²)
Key ideas
  1. Every reading is truth plus noise. The Kalman filter fuses noisy sources by predicting, then correcting.
  2. Mean μ = centre. Variance σ² = the true spread; from samples we estimate it with s², the average squared distance from the mean. σ = √σ².
  3. Gaussians: 68% within ±1σ, 95% within ±2σ. Independent sums: means add, variances add. Var(a x) = a² Var(x).
  4. Small variance = trustworthy sensor. Fusion leans toward it with gain K, and the fused variance is smaller than both.
  • What the filter is. A data-fusion algorithm. Every sensor reports truth plus noise. The filter predicts from the measured motion, then corrects with each new reading. It flew Apollo and runs in drones, robots, cars and phones.
  • Random variables. A reading is one sample of a random variable. From samples: μ is their average, the sample variance s² is the average of (zᵢ − μ)² (our estimate of the true σ²), and s is its square root, in the same units as the readings.
  • The Gaussian. N(μ, σ²) is set by two numbers. About 68% of samples land within ±1σ, about 95% within ±2σ. For independent variables, means and variances add, and scaling by a multiplies the variance by a².
  • Sensor quality. z = x + e with e ~ N(0, σ²). A small σ² means a tall, narrow bell and a sensor to trust. Averaging n readings divides the variance by n, but it cannot remove a bias.
  • Data fusion. x̂ = z₁ + K (z₂ − z₁) with K = σ₁² / (σ₁² + σ₂²). The fused variance σ₁² σ₂² / (σ₁² + σ₂²) is smaller than both, because precisions add: 1/σ̂² = 1/σ₁² + 1/σ₂².
The whole lesson in one picture: two noisy bells fuse into one narrower bell, pulled toward the better sensor.

Next lesson: the one-dimensional Kalman filter

A robot on a line with a wheel encoder and a GPS. The encoder's step becomes the predict step (means add, variances add). The GPS reading becomes the correct step, with the very same gain K. You will run the full filter and watch it beat both sensors.

Read along

Roger Labbe's free book Kalman and Bayesian Filters in Python covers the same ground in its chapters on Gaussians and probabilities (on GitHub). The original paper is R. E. Kalman, "A New Approach to Linear Filtering and Prediction Problems" (1960).

Examples

Example 1

Find the mean, variance and standard deviation of the readings 12, 15 and 9.

Show solutionHide solution

μ = 36 / 3 = 12. Distances: 0, +3, −3. Squares: 0, 9, 9.

s² = 18 / 3 = 6 and s = √6 ≈ 2.45.

Example 2

x ~ N(10, 3) and y ~ N(2, 1) are independent. Find the distribution of 2(x + y).

Show solutionHide solution

First the sum: x + y ~ N(12, 4).

Then scale by a = 2: the mean becomes 24 and the variance 2² · 4 = 16. So 2(x + y) ~ N(24, 16), with σ = 4.

Example 3

Sensor 1 reads 8 with variance 3. Sensor 2 reads 12 with variance 1. Fuse them.

Show solutionHide solution

K = 3 / (3 + 1) = 0.75. x̂ = 8 + 0.75 · (12 − 8) = 11.

σ̂² = 3 · 1 / 4 = 0.75, below both 3 and 1. Check: 1/3 + 1/1 = 4/3, and 1 / (4/3) = 0.75 ✓

Exercise Free play, two tasks (many answers are right). 1. Keep the readings 10 and 16 and pick var1 and var2 so the fused estimate is exactly 12 (hint: you need K = 1/3, so var2 must be twice var1). 2. Raise the sample count (the last number, 30, in each np.random.normal call) to 300 and watch each bell's dots fill in. 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.

Enjoying lesson 1? Get the full course: all 4 lessons through the matrix filter and the EKF, your progress saved lesson by lesson, every solution and 5 extra problems per lesson. $20 once, yours for life.

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