TactivergeOffline

Level 5 Independent Engineering Research · Term 2: Estimation and Autonomous Systems

How autonomous machines know where they are: probability distributions and the central limit theorem, estimators and their bias and variance, measurement uncertainty, Bayesian updating, state-space models, dead reckoning, sensor fusion and the one-dimensional Kalman filter. From week 14 the same ideas steer spacecraft: inertial sensors and star trackers, orbits and Hohmann transfers, light-time delay and navigation budgets.

In this file: 27 lessons across weeks 10–18, with 117 practice questions (questions only, no answers).

Conduct an independent, reproducible engineering investigation using advanced mathematics, estimation and computing, and communicate it to the standard of an early research publication. Levels describe what you can do, not your age. About About 3–4 hours a week: 1.5 hours of study, 1.5–2 hours of computation or research work and 30 minutes of writing. Research weeks are self-paced within that budget..

Week 10: Probability distributions

This week you will

Random variables, expectation and variance

A rover's camera finds its landmark 7 times in 10. Is that a good camera or a lucky day? First we need a number for 'how much does this wobble'.

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Every estimator you meet this term, from an average to a Kalman filter, is a function of random variables. Their expectation tells you where an estimate lands on average; their variance tells you how far it scatters. Get these two numbers right and you can predict how well a robot will know where it is before you build it.

Goals

Predict

A fair die is rolled. You win the number shown, doubled, plus 1. What is your expected winnings?

  1. 7
  2. 8
  3. 3.5
  4. 6

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the Code Lab, simulate 10,000 rolls of a fair die. Compute the mean and the variance of your rolls, then of 2·roll + 1. Compare with 3.5, 35/12 ≈ 2.92, 8 and 4 × 35/12 ≈ 11.67.

What the interactive shows, in words

The Code Lab activity can be done with a calculator: list the six die faces with probability 1/6 each, compute Σx/6 = 3.5 and Σx²/6 − 3.5² = 35/12, then repeat for 2x + 1 to get 8 and 4 × 35/12.

Understand

A random variable is a number from chance

A random variable X assigns a number to each outcome of an experiment: the number of sightings in 10 tries, the error of one range reading. A discrete X has a probability mass function p(x) = P(X = x), with every p(x) ≥ 0 and Σ p(x) = 1.

Expectation: the balance point

E[X] = Σ x·p(x). It is the long-run average over many repeats, not necessarily a value X can take (a die never shows 3.5). Expectation is linear: E[aX + bY + c] = aE[X] + bE[Y] + c, even if X and Y are dependent.

Variance: the typical squared wobble

Var(X) = E[(X − μ)²] = E[X²] − (E[X])², and the standard deviation σ = √Var(X) has the same units as X. Shifting X does not change its spread, scaling does: Var(aX + b) = a²·Var(X). For independent X and Y, Var(X + Y) = Var(X) + Var(Y): variances add, standard deviations do not.

Explain it another way: intuitive

Expectation is where a see-saw holding all the outcomes (weighted by probability) would balance. Variance is how far, on average, the weights sit from that pivot, measured in squared distance so left and right do not cancel.

Explain it another way: technical

For a discrete random variable, E[g(X)] = Σ g(x)p(x). Variance is the second central moment. Independence lets the cross term 2Cov(X, Y) vanish in Var(X + Y) = Var(X) + Var(Y) + 2Cov(X, Y).

Explain it another way: mathematical

Die: E[X] = (1+…+6)/6 = 3.5; E[X²] = 91/6; Var(X) = 91/6 − 12.25 = 35/12 ≈ 2.917. Sum of two dice: E = 7, Var = 35/6. The mean of n independent copies has variance σ²/n.

Explain it another way: applied

A rover's total odometry error over 100 steps is the sum of 100 step errors. If each has variance 0.01 m² and they are independent, the total has variance 1 m², σ = 1 m: errors grow like √n, not n, unless there is a bias.

Try these examples

Example 1

X takes values 0, 1, 2, 3 with probabilities 0.1, 0.2, 0.3, 0.4. Find E[X] and Var(X).

The worked solution is in the online lesson.

Example 2

Each of 25 independent wheel steps has error with σ = 2 cm and mean 0. What is the σ of the total error?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. What is the variance of 3X + 5, where X is one roll of a fair die (Var(X) = 35/12)?

Answer:

2. A drone's number of failed sensor checks per flight, X, takes values 0, 1, 2, 3 with probabilities 0.4, 0.3, 0.2, 0.1. What is E[X]?

Answer:

3. Two independent sensors each have error σ = 3 mm. What is the σ of the sum of their errors?

  • 6 mm
  • √18 ≈ 4.24 mm
  • 3 mm
  • 9 mm

4. One reading has σ = 6 cm. What is the σ of the mean of 9 independent readings, in cm?

Answer: cm

5. Which statement is true for ANY two random variables X and Y?

  • E[X + Y] = E[X] + E[Y]
  • Var(X + Y) = Var(X) + Var(Y)
  • E[XY] = E[X]E[Y]
  • σ(X + Y) = σ(X) + σ(Y)

Apply it

A rover takes 400 steps. Each step's odometry error has mean 0.5 cm (slip bias) and σ = 1 cm. Find the expected total error and its σ. Which term dominates, and what does that tell you about fixing biases first?

Reflect

Why is it useful that expectation is linear even when the variables are not independent?

Binomial, Poisson and normal

Counting sightings, counting cosmic-ray hits, measuring a range: three different questions, three distributions engineers reach for again and again.

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

A mission planner asks: how likely are at least 8 good landmark sightings in 10? How many memory bit-flips should the software tolerate per day? How often will a range reading be more than 2σ off? Each has a ready-made answer once you name the distribution.

Goals

Predict

A sensor's errors are normal. Roughly what fraction of readings fall more than 2σ from the true value?

  1. About 32%
  2. About 5%
  3. About 0.3%
  4. About 50%

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Start with Binomial n = 10, p = 0.3 and move the threshold to see P(X ≤ x). Then raise n to 40: when do the bars look normal? Switch to Poisson and check that mean = variance. Finally use the normal curve to find the area within ±2σ.

What the interactive shows, in words

The distribution explorer draws bars (binomial, Poisson) or a curve (normal, uniform) with a movable threshold. Its readout states the mean, variance and P(X ≤ x) in words, so every number can be followed without the picture.

Understand

Binomial: n tries, fixed p

X = number of successes in n independent trials with the same probability p. P(X = k) = C(n, k)·pᵏ(1 − p)ⁿ⁻ᵏ, mean np, variance np(1 − p). Landmark sightings in 10 attempts are binomial if each attempt is independent; dust storms that come in bursts break that assumption.

Poisson: rare events in time

X = number of events in an interval when they happen independently at a steady average rate λ. P(X = k) = e^(−λ)λᵏ/k!, mean λ, variance λ. Bit-flips from radiation, micrometeoroid hits and photon counts in a star tracker pixel are classic Poisson counts.

Normal: sums of many small effects

Density f(x) = (1/(σ√(2π)))·exp(−(x − μ)²/(2σ²)). To find a probability, standardise with z = (x − μ)/σ and look up Φ(z) = P(Z < z): Φ(1) ≈ 0.8413, Φ(1.645) ≈ 0.95, Φ(1.96) ≈ 0.975. Binomial and Poisson both look normal once their mean and variance are large (roughly ≥ 5–10).

Explain it another way: intuitive

Binomial: flip the same biased coin n times. Poisson: stand in the rain and count drops on a tile in one second. Normal: add up lots of little nudges, and the total is bell-shaped.

Explain it another way: technical

Poisson is the limit of Binomial(n, p) as n → ∞ with np = λ fixed. Normal approximations need a continuity correction for small counts: P(X ≤ k) ≈ Φ((k + 0.5 − μ)/σ).

Explain it another way: mathematical

Binomial(10, 0.3): P(X = 3) = 120 × 0.027 × 0.0823543 ≈ 0.2668. Poisson(2): P(X = 0) = e⁻² ≈ 0.1353. Normal: P(X > μ + 1.5σ) = 1 − Φ(1.5) ≈ 0.0668.

Explain it another way: applied

Flight software designers size error-correcting memory from Poisson rates: if λ = 2 upsets per day, the chance of 5 or more in one day is about 5%, so scrubbing memory hourly keeps multiple upsets in one word vanishingly rare.

Try these examples

Example 1

Landmark sightings succeed with p = 0.8 independently. Probability of exactly 8 in 10?

The worked solution is in the online lesson.

Example 2

Range readings are normal with μ = 50 m, σ = 2 m. What is P(reading < 47 m)?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Which count is best modelled as Poisson?

  • Heads in 20 coin flips
  • Cosmic-ray memory upsets in one hour
  • Correct answers in a 10-question quiz
  • The height of a rover's mast

2. A rover's camera spots its landmark on each attempt with probability p = 0.2, independently. In n = 5 attempts, what is the probability of exactly k = 4 sightings? Give a decimal between 0 and 1.

Answer:

3. Cosmic-ray hits flip bits in a spacecraft memory at an average of λ = 1.5 per day (a Poisson process). What is the probability of exactly k = 3 hits tomorrow? Give a decimal.

Answer:

4. A range sensor's readings are normal with mean μ = 50 m and σ = 5 m. What is the probability that one reading is below x = 57.5 m? Give a decimal.

Answer:

5. A camera succeeds with p = 0.25 on each of n = 40 independent attempts. What is the variance of the number of successes?

Answer:

Apply it

A star tracker pixel receives on average λ = 9 photons per frame from a faint star. Use the normal approximation (μ = σ² = 9) to estimate the probability of fewer than 4 photons, which would make the star undetectable. Then explain why longer exposures help.

Reflect

Which assumption of the binomial model would you check first for a real rover camera, and how?

The central limit theorem by simulation

A reading that is either 0 or 10 looks nothing like a bell curve. Average 30 of them and, astonishingly, a bell curve appears. Why?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Kalman filters and least squares assume Gaussian noise. Real noise comes from many small causes: vibration, thermal jitter, quantisation. The central limit theorem is the reason that assumption is so often good enough, and the simulator shows you exactly when it is not.

Goals

Predict

You average n = 25 independent readings, each with σ = 5. What is the σ of the average?

  1. 5
  2. 1
  3. 0.2
  4. 25

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Pick the skewed 0/10 population with n = 1: no bell. Step n through 2, 5, 10, 30. Record the observed spread each time and compare with σ/√n. Then try the exponential population and press 'draw' a few times to see run-to-run variation.

What the interactive shows, in words

The simulator draws 1,000 sample means as a histogram with the predicted normal curve over it. The readout states the observed mean and spread beside σ/√n, so the result can be read entirely as numbers.

Understand

The theorem

If X₁, …, Xₙ are independent with the same mean μ and finite variance σ², then the sample mean X̄ has mean μ and standard deviation σ/√n, and as n grows its distribution approaches Normal(μ, σ²/n) whatever the shape of the Xᵢ.

How big must n be?

For symmetric populations (uniform, a die) n ≈ 5 already looks normal. Skewed or lumpy populations need more: the 0/10 population still looks lopsided at n = 10 and is close to normal by n = 30–100. Heavy-tailed noise with infinite variance never obeys the theorem.

Standard error

σ/√n is the standard error of the mean. It is what makes averaging a powerful but slow tool: 100 readings give 10× precision, 10,000 give 100×. It only shrinks random error; a bias shared by every reading survives any amount of averaging.

Explain it another way: intuitive

Each reading pushes the average up or down a little. With many readings, big pushes in one direction are usually cancelled by pushes the other way, so extreme averages become rare and the middle fills up into a bell.

Explain it another way: technical

The Lindeberg–Lévy CLT: √n(X̄ − μ)/σ converges in distribution to N(0, 1). Independence and identical distribution can be relaxed (Lindeberg condition), but finite variance cannot.

Explain it another way: mathematical

Skewed population: P(10) = 0.1, else 0. μ = 1, E[X²] = 10, σ² = 9, σ = 3. With n = 30, SE = 3/√30 ≈ 0.548, so about 95% of averages fall in 1 ± 1.07.

Explain it another way: applied

IMU data sheets quote noise density precisely because averaging (integrating) many samples turns raw jitter into a predictable Gaussian error that a filter can model.

Try these examples

Example 1

A gyro sample has σ = 0.8 °/s. How many samples must be averaged for SE = 0.1 °/s?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Readings have σ = 4 mm. How many must be averaged to get a standard error of 0.5 mm?

Answer:

2. A star tracker's single attitude measurement has σ = 1 arcseconds. You average n = 64 independent measurements. What is the standard error of the average, in arcseconds?

Answer: arcsec

3. Every reading from a range sensor is 3 cm too long because of a mounting offset, plus random noise σ = 2 cm. After averaging 400 readings, the error of the mean is about…

  • 3 cm (the bias stays) ± 0.1 cm
  • 0.1 cm
  • 0 cm
  • 3 cm ± 2 cm

4. Which condition is essential for the CLT as stated in this lesson?

  • The readings are normally distributed
  • The readings have finite variance and are independent
  • n is at least 1000
  • The population is symmetric

Apply it

Use the simulator to find the smallest n for which the skewed population's sample means look normal to you. Write down your criterion before you look (for example, no bin more than twice the curve's height). Compare with a classmate's criterion: do you agree on n?

Reflect

Why might a filter that assumes Gaussian noise still work well on a rover whose wheel slip is very non-Gaussian on any single step?

Week 11: Statistical estimation

This week you will

Estimators: bias, variance and error

Two ways to locate a landmark: one is always 20 cm off but rock-steady, the other is right on average but scatters by a metre. Which is better?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

An estimator is any recipe that turns readings into a number: an average, a median, a filter. Engineers choose between recipes using two numbers, bias and variance. Learning to see both, rather than just 'is it accurate?', is the core skill of this term.

Goals

Predict

You use '0.7 × the average' instead of the plain average to estimate a position 3.6 m away. What happens?

  1. Less scatter, but systematically too short
  2. More scatter, but unbiased
  3. Exactly the same as the average
  4. Unbiased and less scatter: strictly better

Write down your guess and your reason. The reveal is in the online lesson.

Discover

With no systematic offset, compare 'average of all n', 'first reading only' and '0.7 × average' at n = 5. Record bias, spread and RMSE for each. Then add a 0.5 m sensor offset and see which numbers move.

What the interactive shows, in words

Each dot on the dartboard is one repeated experiment's estimate; the cross marks their centre. The readout gives observed and theoretical bias, spread and RMSE, so the comparison can be made from the numbers alone.

Understand

The estimator is random

An estimator θ̂ = g(X₁, …, Xₙ) is a random variable, because the data are. Imagine repeating the whole experiment many times: each repeat gives a dart on the board. We judge the estimator by the cloud of darts, not by one throw.

Bias and variance

Bias = E[θ̂] − θ: how far the cloud's centre is from the truth. Variance = E[(θ̂ − E[θ̂])²]: how scattered the cloud is. The sample mean is unbiased with variance σ²/n. Using only the first reading is also unbiased, but its variance is σ²: n times worse.

Mean squared error

MSE = E[(θ̂ − θ)²] = bias² + variance. RMSE = √MSE is in the units of θ. A slightly biased estimator can have lower MSE than an unbiased one if it cuts variance enough. That is why filters sometimes deliberately smooth (accepting lag, a bias) to reduce noise.

Explain it another way: intuitive

Bias is aiming at the wrong spot; variance is a shaky hand. You can be steady and wrong, or wobbly and right on average. The total miss distance counts both.

Explain it another way: technical

Consistency: an estimator is consistent if it converges to θ as n → ∞. The sample mean is unbiased and consistent; 0.7 × mean is neither unbiased nor consistent; 'first reading' is unbiased but not consistent.

Explain it another way: mathematical

MSE decomposition: E[(θ̂ − θ)²] = E[(θ̂ − E θ̂)²] + (E θ̂ − θ)², because the cross term 2E[θ̂ − E θ̂](E θ̂ − θ) is zero. For the median of normal data, Var ≈ (π/2)σ²/n for large n: about 57% more variance than the mean.

Explain it another way: applied

A rover's landmark range from the camera is biased if the camera calibration is off. Re-calibration attacks bias; averaging frames attacks variance. Knowing which dominates tells you which to spend effort on.

Try these examples

Example 1

An estimator has bias 0.3 m and standard deviation 0.4 m. What is its RMSE?

The worked solution is in the online lesson.

Example 2

Mean of 16 readings with σ = 2 m versus a single reading: compare RMSE (both unbiased).

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. An estimator has bias 1.2 cm and standard deviation 0.5 cm. What is its RMSE, in cm?

Answer: cm

2. 'Use only the first of n readings' is an estimator that is…

  • Unbiased, but its variance does not shrink with n
  • Biased
  • Unbiased with variance σ²/n
  • Better than the mean when n is large

3. Estimator A: bias 0, σ = 2. Estimator B: bias 0.5, σ = 1. Which has lower MSE?

  • A
  • B
  • They are equal
  • Cannot tell without more data

4. A star tracker's single attitude measurement has σ = 2 arcseconds. You average n = 49 independent measurements. What is the standard error of the average, in arcseconds?

Answer: arcsec

5. For normal data and large n, the median's variance is about (π/2)·σ²/n. How many readings must the median use to match the mean of 100 readings?

Answer:

Apply it

Design a dartboard experiment that shows the median beating the mean. (Hint: think about occasional wild readings, such as a camera mistaking a rock for the landmark.) Describe the noise model you would need and predict the result.

Reflect

When would you deliberately accept a biased estimator on a robot?

Maximum likelihood

A probe's detector counted 12 dust impacts in 4 hours. What impact rate makes that observation least surprising?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

When you have a model with an unknown parameter, maximum likelihood is the default way to fit it: rates of failures, success probabilities, noise variances. It also underlies least squares, the workhorse of calibration.

Goals

Predict

A camera sees the landmark 7 times in 10 attempts (binomial). What is the maximum-likelihood estimate of p?

  1. 0.5
  2. 0.7
  3. 0.75
  4. It depends on the prior

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Keep the flat prior. Add 7 successes and 3 failures. With a flat prior the posterior is just the normalised likelihood, so its peak is the MLE: check it sits at 0.7. Add more data in the same ratio and watch the peak stay put while it narrows.

What the interactive shows, in words

With a flat prior, the grid's posterior bars are the normalised likelihood; the readout states the peak value and k/n, which match. All values appear in the text readout.

Understand

Likelihood

Given a model P(data | θ), the likelihood L(θ) is that same expression read as a function of θ, with the data fixed. It is not a probability distribution over θ (it need not integrate to 1). The MLE θ̂ maximises L, or equivalently the log-likelihood ℓ = ln L, which turns products into sums.

Two classic results

Binomial: ℓ(p) = k ln p + (n − k) ln(1 − p) + c; dℓ/dp = 0 gives p̂ = k/n. Poisson with rate λ over time T: ℓ(λ) = k ln(λT) − λT + c; dℓ/dλ = k/λ − T = 0 gives λ̂ = k/T. The MLE is usually the 'obvious' estimate, now with a justification.

Gaussian noise gives least squares

If yᵢ = f(xᵢ; θ) + εᵢ with εᵢ ~ N(0, σ²) independent, then ℓ(θ) = −Σ(yᵢ − f(xᵢ; θ))²/(2σ²) + c. Maximising ℓ is minimising the sum of squared residuals. Least squares is the MLE when the noise is Gaussian, and only then is it guaranteed optimal in this sense.

Explain it another way: intuitive

Try every possible rate. For each, ask 'how likely was what I saw?' Pick the rate that makes your data least surprising.

Explain it another way: technical

Under regularity conditions the MLE is consistent and asymptotically normal with variance 1/I(θ), the inverse Fisher information. For Poisson, I(λ) = T/λ, so SE(λ̂) ≈ √(λ̂/T).

Explain it another way: mathematical

Binomial: d/dp [k ln p + (n − k) ln(1 − p)] = k/p − (n − k)/(1 − p) = 0 ⇒ k(1 − p) = (n − k)p ⇒ p = k/n.

Explain it another way: applied

Reliability engineers estimate failure rates of components from test hours with exactly this formula, then use the SE to decide how many more test hours are needed.

Derivation: The MLE of a Poisson rate
  1. k events in time T, rate λ: P(k | λ) = e^(−λT)(λT)ᵏ / k!.

  2. Log-likelihood: ℓ(λ) = −λT + k ln λ + k ln T − ln k!.

  3. Differentiate: dℓ/dλ = −T + k/λ.

  4. Set to zero: λ̂ = k/T. Second derivative −k/λ² < 0, so it is a maximum.

  5. Example: 12 impacts in 4 h gives λ̂ = 3 per hour.

Try these examples

Example 1

12 micrometeoroid impacts are recorded in 4 hours. MLE of the rate and its approximate standard error?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A gripper succeeds 18 times in 24 attempts. What is the maximum-likelihood estimate of its success probability?

Answer:

2. A micrometeoroid detector on a probe records k = 12 impacts in T = 12 hours. Assuming a Poisson process with rate λ, what is the maximum-likelihood estimate of λ, in impacts per hour?

Answer: per hour

3. Least squares is the maximum-likelihood fit when the measurement noise is…

  • Independent Gaussian with equal variance
  • Uniform
  • Poisson
  • Any distribution with mean zero

4. Which is true of the likelihood L(θ)?

  • It is a probability distribution over θ
  • It is the probability of the data, viewed as a function of θ
  • It always integrates to 1 over θ
  • It includes a prior on θ

5. A detector records 50 events in 200 s. Using SE ≈ √(λ̂/T), what is the standard error of the rate, in events per second?

Answer: per s

Apply it

Your rover's hazard camera false-alarms 3 times in 600 frames. Estimate the false-alarm rate and its standard error. How many frames would you need to halve the SE?

Reflect

Why do we usually maximise the log-likelihood instead of the likelihood itself?

Least squares as an estimator

A rover logs its position every second. Fitting a line gives its speed. How sure can you be of that speed?

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Calibrating a sensor, estimating a drift rate, fitting a motor model: each is a least-squares problem. Reporting the fitted value without its uncertainty is half an answer.

Goals

Predict

You fit a line to 5 points, then to 20 points spread over the same time span with the same noise. The slope's standard error…

  1. Halves (roughly)
  2. Stays the same
  3. Quarters
  4. Doubles

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the Code Lab, generate y = 1.5x + 2 plus Gaussian noise (σ = 0.3) at x = 0…4. Fit the line with the normal equations, repeat 1,000 times with new noise, and compare the spread of your fitted slopes with σ/√Σ(x − x̄)² = 0.3/√10 ≈ 0.095.

What the interactive shows, in words

The Code Lab task is a calculation that can be done by hand with the sums Σx, Σy, Σxy and Σx²; the expected spread of slopes, 0.095, is stated in the instructions.

Understand

The model and the criterion

Model: yᵢ = m·xᵢ + c + εᵢ. Least squares picks m, c to minimise S = Σ(yᵢ − mxᵢ − c)². Setting ∂S/∂m = ∂S/∂c = 0 gives the normal equations; their solution is m̂ = Σ(xᵢ − x̄)(yᵢ − ȳ) / Σ(xᵢ − x̄)² and ĉ = ȳ − m̂x̄.

Matrix form

Stack the data as y = Aθ + ε with A's rows [xᵢ, 1] and θ = [m, c]ᵀ. The estimate is θ̂ = (AᵀA)⁻¹Aᵀy, the same formula for any linear-in-parameters model (polynomials, sensor calibration curves). With noise variance σ², Cov(θ̂) = σ²(AᵀA)⁻¹.

How certain is the slope?

From that covariance, SE(m̂) = σ/√Σ(xᵢ − x̄)². Spreading the x-values out, or taking more points, shrinks it. If σ is unknown, estimate it from the residuals: s² = Σ rᵢ²/(n − 2), dividing by n − 2 because two parameters were fitted.

Explain it another way: intuitive

Hang the line on springs attached to every point, each spring pulling with force proportional to the vertical gap. Where the line settles is the least-squares fit: big gaps pull hardest.

Explain it another way: technical

Gauss–Markov: with zero-mean, uncorrelated, equal-variance errors, θ̂ is the best linear unbiased estimator (lowest variance among linear unbiased estimators), even if the noise is not Gaussian.

Explain it another way: mathematical

x = 0…4: x̄ = 2, Σ(x − x̄)² = 10. With σ = 0.3, SE(m̂) = 0.3/√10 ≈ 0.095. Intercept variance σ²(1/n + x̄²/Σ(x − x̄)²) = 0.09 × (0.2 + 0.4) = 0.054, SE ≈ 0.23.

Explain it another way: applied

A gyro's bias drift is estimated by fitting a line to its output while stationary. The slope's SE tells you whether the drift is real or just noise.

Derivation: The least-squares slope
  1. S(m, c) = Σ(yᵢ − mxᵢ − c)².

  2. ∂S/∂c = −2Σ(yᵢ − mxᵢ − c) = 0 ⇒ c = ȳ − m x̄.

  3. Substitute: S = Σ((yᵢ − ȳ) − m(xᵢ − x̄))².

  4. ∂S/∂m = −2Σ(xᵢ − x̄)((yᵢ − ȳ) − m(xᵢ − x̄)) = 0.

  5. So m̂ = Σ(xᵢ − x̄)(yᵢ − ȳ) / Σ(xᵢ − x̄)², which equals (nΣxy − ΣxΣy)/(nΣx² − (Σx)²).

Try these examples

Example 1

Points (0, 2.1), (1, 3.4), (2, 5.2), (3, 6.4), (4, 8.1). Find the slope.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A line is fitted at x = 0, 1, 2, 3, 4 with noise σ = 0.5. What is the standard error of the slope?

Answer:

2. A rover logs its odometer distance y (m) at times x = 0, 1, 2, 3, 4 s: y = 4.9, 5.8, 7.2, 8.2, 8.8. What is the least-squares slope (speed estimate) in m/s?

Answer: m/s

3. To estimate a drift rate as precisely as possible with 10 measurements over a fixed hour, you should take them…

  • 5 at the start and 5 at the end
  • All in the middle
  • Evenly spaced
  • All at the end

4. Why divide the residual sum of squares by n − 2 to estimate σ² in a straight-line fit?

  • Two parameters were fitted from the data, using up two degrees of freedom
  • It is a convention with no reason
  • To make the estimate smaller
  • Because the first and last points are excluded

Apply it

Fit a line to five odometer logs from the generator, estimate σ from the residuals (divide by n − 2), and report the speed as m̂ ± 2·SE. Is the rover's speed significantly different from the commanded 1.5 m/s?

Reflect

Least squares assumes the x-values are exact. What would change if timestamps were noisy too?

Week 12: Measurement uncertainty

This week you will

Random and systematic error, and confidence intervals

Your thousand-reading average has a tiny error bar. Then someone notices the sensor was mounted 2 cm off. What did the error bar actually promise?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Every number in a research report carries an uncertainty, and readers act on it. A confidence interval that ignores systematic error is not just incomplete: it is confidently wrong. This lesson is the module check's backbone.

Goals

Predict

A 95% confidence interval for a rover's mean wheel radius is 101.2 ± 0.3 mm. Which statement is correct?

  1. 95% of wheels have radius in that range
  2. If we repeated the procedure many times, about 95% of such intervals would contain the true mean
  3. There is a 95% chance the true mean is exactly 101.2
  4. The radius is definitely between 100.9 and 101.5

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Use 'average of all n' with n = 20. With zero offset the cloud is centred: random error only. Now set a 0.8 m offset: the cloud moves but stays the same size. Increase n: the cloud shrinks around the WRONG point. That is a precise, inaccurate measurement.

What the interactive shows, in words

On the dartboard, a systematic offset shifts the whole cloud of estimates away from the bullseye while larger n only shrinks it; the readout states the bias and spread numerically.

Understand

Two kinds of error

Random error changes from reading to reading (noise, vibration); it shows up as scatter and shrinks with averaging. Systematic error is the same each time (calibration, mounting offset, wrong model); it shows up as bias and is invisible in the scatter. Accuracy needs both small; precision only needs the first.

Confidence interval for a mean

With n readings, mean x̄ and standard deviation s, a large-n 95% interval is x̄ ± 1.96·s/√n. For small n use Student's t (for n = 10, t ≈ 2.26 instead of 1.96). The half-width is the expanded uncertainty with coverage factor about 2.

Reporting honestly

Write value ± uncertainty (unit, coverage), e.g. 101.2 ± 0.3 mm (95%, random only). State what is included. Estimate systematic terms separately (calibration certificate, a check against a reference) and combine them with the random term in quadrature if independent.

Explain it another way: intuitive

Random error is a shaky hand; systematic error is a bent ruler. Measuring many times steadies the hand but never straightens the ruler.

Explain it another way: technical

The GUM (Guide to the Expression of Uncertainty in Measurement) calls these Type A (evaluated statistically from repeats) and Type B (evaluated by other means, such as specifications). Both are expressed as standard uncertainties and combined.

Explain it another way: mathematical

n = 36, s = 1.2 mm: SE = 0.2 mm, 95% half-width = 0.392 mm. Adding a 0.3 mm (1σ) calibration term: combined u = √(0.2² + 0.3²) = 0.36 mm, expanded ≈ 0.72 mm.

Explain it another way: applied

Mars rover position estimates are reported with covariances, but navigators also check them against orbital imagery: an independent reference that exposes systematic errors the filter cannot see.

Try these examples

Example 1

25 range readings: mean 12.40 m, s = 0.10 m. Give a 95% interval (use 1.96).

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. n = 16 readings of a wheel's radius have standard deviation s = 2 mm. Using z = 1.96 (large n), what is the half-width of the 95% confidence interval for the mean radius, in mm?

Answer: mm

2. Which of these is a systematic error?

  • A thermometer that reads 0.5 °C high every time
  • Electrical noise on an ADC reading
  • Vibration shaking a camera
  • Quantisation of a reading to the nearest step

3. A mean has random standard uncertainty 0.4 mm and an independent calibration standard uncertainty 0.3 mm. What is the combined standard uncertainty, in mm?

Answer: mm

4. Two teams report 9.81 ± 0.02 and 9.75 ± 0.02 m/s² (95%) for the same quantity. What is the most likely explanation?

  • At least one has an unaccounted systematic error
  • Both are right; the intervals just differ
  • The second team used fewer readings
  • Random error explains it

Apply it

Pick a measurement from this term's rover project (for example, final position error). List one random and one systematic source of error, say how you would estimate each, and write the result in the form value ± uncertainty (coverage, what is included).

Reflect

What is one systematic error in a simulation study that repeated runs would never reveal?

Propagating uncertainty: linearisation and Monte Carlo

You know the wheel's circumference to 1% and the turn count to 2%. How well do you know the distance? And what if the formula is not so simple?

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Engineering answers are calculated from measured inputs. Uncertainty propagation tells you how input errors become output errors, and which input to improve. When the function bends sharply, Monte Carlo keeps you honest.

Goals

Predict

Area of a square solar panel A = L². L has 2% uncertainty. What is A's relative uncertainty?

  1. 2%
  2. 4%
  3. √2 × 2% ≈ 2.8%
  4. 1%

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the Code Lab, sample L ~ Normal(1.00, 0.02) 100,000 times, compute A = L² and the standard deviation of A. Compare with the linearised 4%. Then try h = 1/L with L ~ Normal(1, 0.3): the Monte Carlo mean is not 1/1 and the spread is lopsided. Linearisation breaks when the function curves strongly within the uncertainty.

What the interactive shows, in words

The Code Lab activity's expected results are stated in the text: about 4% spread for L² and a biased, skewed result for 1/L with large uncertainty. The rules can all be applied with a calculator.

Understand

First-order propagation

For y = f(x₁, …, xₙ) with independent inputs, σ_y² ≈ Σ (∂f/∂xᵢ)² σᵢ². This is a Taylor expansion to first order: it treats f as a plane near the measured point. It is exact for linear functions and good when σᵢ is small compared with the scale on which f bends.

Handy rules

Sums and differences: absolute uncertainties add in quadrature. Products and quotients: relative uncertainties add in quadrature. Powers: y = xⁿ gives σ_y/y = |n|·σ_x/x. Correlated inputs need the covariance term 2(∂f/∂x)(∂f/∂y)Cov(x, y).

Monte Carlo propagation

Draw many input samples from their distributions, push each through f, and look at the outputs. No derivatives needed, nonlinearity and correlation handled automatically, and you get the whole output distribution. The cost is computation and the need for honest input distributions.

Explain it another way: intuitive

Wiggle each input by its uncertainty and see how much the output wiggles. Independent wiggles partly cancel, so you combine them like perpendicular sides of a triangle.

Explain it another way: technical

The first-order (delta) method also gives the output mean as f(x̄). The second-order correction to the mean is ½Σ(∂²f/∂xᵢ²)σᵢ²: for 1/L with σ = 0.3 that is +0.09, the bias Monte Carlo reveals.

Explain it another way: mathematical

Distance d = C·N, σ_C/C = 1%, σ_N/N = 2%: σ_d/d = √(1² + 2²)% ≈ 2.24%. Range from light time r = c·t/2 with σ_t = 10 ns: σ_r = c·σ_t/2 = 1.5 m.

Explain it another way: applied

Mission designers run Monte Carlo campaigns of thousands of simulated landings, sampling atmosphere, aerodynamics and navigation errors, because entry dynamics are far too nonlinear for linearised propagation alone.

Try these examples

Example 1

Speed v = d/t with d = 100.0 ± 0.5 m and t = 20.0 ± 0.2 s (independent). Find v ± σ_v.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Distance driven = wheel circumference × number of turns. The circumference has a 1% relative uncertainty and the turn count a 3% relative uncertainty (independent). The rover drove about 400 m. What is the relative uncertainty of the distance, in %?

Answer: %

2. A position is the sum of two independent legs: 40.0 ± 0.3 m and 25.0 ± 0.4 m. What is the standard uncertainty of the total, in m?

Answer: m

3. Kinetic energy ½mv² with mass known exactly and v uncertain by 3%. What is the relative uncertainty of the energy, in %?

Answer: %

4. When is Monte Carlo propagation clearly better than linearisation?

  • When the function is strongly nonlinear over the input uncertainty
  • When the function is linear
  • When the inputs are known exactly
  • Never: they always agree

Apply it

A rover estimates distance to a cliff from camera disparity: Z = f·B/d with focal length f = 800 px, baseline B = 0.2 m and disparity d = 16 ± 1 px. Propagate by linearisation, then reason about (or run) a Monte Carlo check. Which method would you trust for d = 4 ± 1 px?

Reflect

Which input in your own project measurement contributes most to the output uncertainty, and how did you find out?

Error budgets: where does the uncertainty come from?

A landing has six independent sources of position error. Halving the smallest one saves almost nothing. Halving the biggest saves a lot. How do you know which is which?

About 35 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Big engineering programmes manage uncertainty with budgets, just like mass and power. Each subsystem is given an allowance; the budget shows where effort pays. It is the bridge from statistics to design decisions.

Goals

Predict

Three independent errors: 3 m, 4 m and 1 m (1σ). Roughly what is the total?

  1. 8 m
  2. 5.1 m
  3. 4 m
  4. 12 m

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the fusion lab, set the filter to Kalman and record the position RMSE with default settings. Then change one error source at a time (camera noise, odometry noise, odometry bias, dropout) by a factor of two and record the new RMSE. Rank the sources by how much they matter: that is an empirical error budget.

What the interactive shows, in words

The fusion lab experiment can be recorded as a table: error source, its setting, and the resulting RMSE. The ranking comes from the numbers, not the plot.

Understand

Root-sum-square

If contributions eᵢ are independent with standard deviations σᵢ, the total σ = √(Σσᵢ²). Squares make the big terms dominate: a term half the size of the largest contributes only a quarter as much variance.

Sensitivity and payoff

∂σ/∂σᵢ = σᵢ/σ. Improving the largest term pays most. A good budget lists each term, its source, how it was estimated (test, analysis, data sheet) and its share of total variance σᵢ²/σ².

Allocation and margin

Work backwards from a requirement: if the landing must be within 10 km (3σ), the total 1σ must be ≤ 3.3 km. Allocate that among subsystems so the RSS fits, keeping margin for errors not yet understood. Correlated terms must be combined with their covariance, or added linearly as a conservative bound.

Explain it another way: intuitive

Errors are like noise from several loudspeakers at once. The loudest speaker sets how noisy the room is; turning down the quiet ones barely helps.

Explain it another way: technical

This is variance decomposition. For nonlinear systems the same idea is done with Monte Carlo and sensitivity indices (such as Sobol indices) instead of a simple sum.

Explain it another way: mathematical

Budget 2, 6, 5, 1.5 km: total = √(4 + 36 + 25 + 2.25) = √67.25 ≈ 8.20 km. Halving the 6 km term: √(4 + 9 + 25 + 2.25) ≈ 6.34 km. Halving the 1.5 km term: √(4 + 36 + 25 + 0.5625) ≈ 8.10 km.

Explain it another way: applied

Mars landing ellipses are built from such budgets: entry navigation, atmosphere density, aerodynamics and timing each contribute, and the dominant term has historically driven the next mission's technology choices.

Try these examples

Example 1

Contributions 2, 6, 5 and 1.5 km. Total, and the share of variance from the 6 km term?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A landing-position error budget has four independent 1σ contributions: entry navigation 2 km, atmosphere 2 km, aerodynamics 5 km and timing 2.5 km. What is the combined 1σ error (root-sum-square), in km?

Answer: km

2. Terms of 3, 4 and 12 m (1σ). What percentage of total variance comes from the 12 m term?

Answer: %

3. A requirement allows a total of 5 m (1σ). Two terms are already 3 m and 2 m. What is the largest allowed third term, in m?

Answer: m

4. A budget has terms 1, 2 and 8 m. You can halve any one term. Which gives the biggest improvement?

  • Halve the 8 m term
  • Halve the 1 m term
  • Halve the 2 m term
  • All give the same improvement

Apply it

Write a four-line error budget for the rover's position after a 40 m drive (odometry noise, slip bias, heading error, camera fix). Estimate each term from this term's lessons or the fusion lab, give the total, and say which one you would attack first.

Reflect

What would make you add two error terms linearly instead of in quadrature?

Week 13: Bayesian intuition

This week you will

Bayes' rule for sensor readings

The hazard detector beeps. It catches 90% of real hazards and false-alarms only 5% of the time. Is the rock really dangerous? Probably less likely than you think.

About 35 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

An autonomous system never sees the truth, only evidence. Bayes' rule is the exact recipe for turning evidence into belief, and it explains why rare events plus imperfect sensors produce so many false alarms.

Goals

Predict

Hazards are 10% of rocks. The detector fires for 90% of hazards and for 5% of safe rocks. It fires. Probability it is a hazard?

  1. 90%
  2. About 67%
  3. 95%
  4. 10%

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the Code Lab, simulate 100,000 rocks: 10% hazards, a detector with 90% hit rate and 5% false-alarm rate. Among rocks where the detector fired, count the fraction that are hazards. Then fire a second, independent detector and update again.

What the interactive shows, in words

The Code Lab simulation's result can be checked by the 1,000-rock counting argument in the intuitive mode: 90 true alarms and 45 false alarms out of 135.

Understand

The rule

P(H | E) = P(E | H)·P(H) / P(E), with P(E) = Σ P(E | Hᵢ)P(Hᵢ) over all hypotheses. Prior P(H): belief before the reading. Likelihood P(E | H): how probable the reading is if H is true. Posterior P(H | E): belief after.

Base rates matter

A good sensor on a rare event still gives many false alarms. With a 1% prior, even a 99%-accurate detector with a 1% false-alarm rate gives a posterior of only 50%. Ignoring the prior is the base-rate fallacy.

Updating repeatedly

Today's posterior is tomorrow's prior. Two independent readings multiply their likelihoods. After two alarms from independent detectors in the example, P(hazard) rises from 0.67 to about 0.97. Independence is crucial: two looks by the same camera at the same shadow are not independent evidence.

Explain it another way: intuitive

Imagine 1,000 rocks. 100 are hazards; the detector flags 90 of them. Of 900 safe rocks it flags 45. So of 135 flags, 90 are real: two-thirds.

Explain it another way: technical

In odds form: posterior odds = likelihood ratio × prior odds. Here LR = 0.9/0.05 = 18 and prior odds 1:9, so posterior odds 2:1, P = 2/3. Logs of LRs add for independent evidence.

Explain it another way: mathematical

P(H | E₁, E₂) ∝ P(E₂ | H)P(E₁ | H)P(H) when E₁, E₂ are conditionally independent given H. Second update: 0.9 × 0.667 / (0.9 × 0.667 + 0.05 × 0.333) ≈ 0.973.

Explain it another way: applied

Autonomous rovers combine evidence from stereo cameras and hazard cameras before refusing a path. Too high a threshold and they stop at every shadow; too low and they drive into rocks.

Try these examples

Example 1

Prior 0.02, hit rate 0.95, false-alarm rate 0.02. Posterior after one alarm?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Prior P(H) = 0.2. P(E | H) = 0.8, P(E | not H) = 0.1. What is P(H | E)?

Answer:

2. Before looking, a rover believes there is a 0.02 probability that a rock ahead is a hazard. Its hazard detector fires with probability 0.99 when there is a hazard and 0.02 when there is not. The detector fires. What is the posterior probability of a hazard?

Answer:

3. A dust-storm alarm is 99% sensitive and has a 1% false-alarm rate, but storms occur on only 1% of sols. After an alarm, P(storm) is about…

  • 99%
  • 50%
  • 1%
  • 90%

4. The same camera takes two photos of a rock one second apart; both look like a hazard. Why should you NOT simply apply the update twice?

  • The two readings share the same lighting and viewpoint, so they are not independent evidence
  • Bayes' rule only works once
  • The prior becomes negative
  • Two photos always cancel

Apply it

Choose a detection threshold for a rover hazard detector. Write down the cost of a missed hazard and the cost of a false stop, then use Bayes' rule with two candidate (hit, false-alarm) pairs to argue which threshold is better.

Reflect

Where in everyday life have you seen the base-rate fallacy?

Updating a belief on a grid

Instead of 'hazard or not', what if the unknown can be any number between 0 and 1? Split it into 21 slices and let the data reshape them.

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Grid updating is Bayes' rule with many hypotheses at once. It is how a rover can track 'what fraction of sightings work today' or, in robot localisation, 'which grid cell am I in'. It also makes priors visible: you can watch the data overpower them.

Goals

Predict

With a prior that says 'the camera is probably good (≈ 0.75)', you see 1 success and 1 failure. The posterior mean will be…

  1. Exactly 0.5
  2. Above 0.5, pulled by the prior
  3. Below 0.5
  4. Exactly 0.75

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Pick 'Probably good'. Add one success and one failure: note the posterior mean. Now add 20 more in a 50:50 ratio. The prior's pull fades. Repeat with 'Probably poor' and check both posteriors converge.

What the interactive shows, in words

The grid shows 21 bars for the posterior plus prior and likelihood lines. The readout lists the data as ticks and crosses and states MAP, posterior mean, P(p > 0.5) and k/n.

Understand

The grid recipe
  1. Choose grid values p₁…p_m. 2. Assign prior weights π(pⱼ) summing to 1. 3. For the data, compute the likelihood L(pⱼ) = pⱼᵏ(1 − pⱼ)ⁿ⁻ᵏ. 4. Multiply: πⱼ·Lⱼ. 5. Normalise by the sum. That is the posterior: a full distribution over the unknown.
Summaries

The MAP (maximum a posteriori) is the highest bar. The posterior mean Σ pⱼ·postⱼ balances the bars. A credible probability such as P(p > 0.5 | data) is the sum of bars above 0.5: a direct answer to 'how sure are we the camera is better than a coin?'

Prior versus data

With a flat prior, the posterior is the normalised likelihood and its peak is the MLE k/n. Informative priors matter when data are scarce and fade as n grows. A grid is simple and exact for one or two parameters, but the number of cells explodes in high dimensions: that is why filters use Gaussians instead.

Explain it another way: intuitive

Start with a row of 21 buckets of sand, one per possible success rate, piled according to your prior. Each observation lets some sand drain from buckets that explain it badly. Whatever sand is left, rescaled to a full load, is your new belief.

Explain it another way: technical

With a Beta(a, b) prior the posterior is Beta(a + k, b + n − k) exactly (conjugacy). The grid approximates this for any prior shape, including ones with no formula.

Explain it another way: mathematical

Flat prior, k = 3, n = 4: posterior ∝ p³(1 − p). Continuous posterior mean (k + 1)/(n + 2) = 4/6 ≈ 0.667; MAP = k/n = 0.75. The 21-point grid reproduces both closely.

Explain it another way: applied

Markov localisation for robots uses exactly this, with the grid over positions: predict by shifting the belief with odometry, update by multiplying by the sensor likelihood. The term project's 'where is the rover?' question can be answered that way too.

Try these examples

Example 1

Three hypotheses for p: 0.2, 0.5, 0.8, equal prior. One success observed. Posterior?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Hypotheses p = 0.2, 0.5, 0.8 with equal prior. You observe one FAILURE. What is the posterior probability of p = 0.2?

Answer:

2. Same three hypotheses, equal prior. You observe success then failure. What is the posterior of p = 0.5?

Answer:

3. With a flat prior, where is the posterior's peak?

  • At the maximum-likelihood estimate
  • At 0.5 always
  • At the posterior mean
  • Nowhere: a flat prior gives a flat posterior

4. Why do robots rarely use plain grids to estimate 6-D pose (3 position + 3 orientation)?

  • The number of cells grows exponentially with dimension
  • Bayes' rule fails in 6-D
  • Grids cannot represent uncertainty
  • Priors cannot be defined in 6-D

Apply it

Use the grid with each of the three priors and the same 6 successes in 10 attempts. Report P(p > 0.5) for each. How many observations (at the same ratio) until all three agree within 0.05?

Reflect

What prior would you choose for a brand-new camera you have never tested, and why?

The conjugate normal update

Your map says the crater is 20 m away (± 3 m). The lidar says 24 m (± 2 m). Where is it, and how sure are you now?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

When everything is Gaussian, Bayes' rule collapses to two lines of arithmetic. Those two lines are the heart of every Kalman filter flying today. Derive them once and the filter will never be a black box.

Goals

Predict

Prior N(20, 3²) and measurement 24 with σ = 2. The posterior mean is…

  1. 22, halfway
  2. About 22.8, nearer the measurement
  3. 24, trust the sensor
  4. About 21.2, nearer the prior

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Treat sensor 1 as the prior (z₁ = 20, σ₁ = 3) and sensor 2 as the lidar (z₂ = 24, σ₂ = 2). Snap w to the optimum: the fused curve is the posterior. Check the readout against 22.77 m and 1.66 m.

What the interactive shows, in words

The fusion diagram plots two normal curves and their optimal combination; the readout states the fused mean and σ, which equal the posterior here (22.77 m and 1.66 m for the suggested values).

Understand

Precisions add

Precision is 1/σ². After the update, posterior precision = prior precision + measurement precision. The posterior σ is therefore always smaller than both σ₀ and σ: information never hurts, if the models are right.

Precision-weighted mean

The posterior mean is the average of μ₀ and z weighted by their precisions. Equivalently, start at the prior and move a fraction K = σ₀²/(σ₀² + σ²) of the way towards the measurement. z − μ₀ is the innovation: the surprise the measurement brought.

Conjugacy

A prior is conjugate to a likelihood when the posterior has the same family as the prior. Normal–normal is the most useful case: a Gaussian belief stays Gaussian after every update, so a filter only ever stores a mean and a variance.

Explain it another way: intuitive

Two people guess where the crater is. One is usually within 3 m, the other within 2 m. You trust the better one more, but not completely, and combining them makes you more confident than either alone.

Explain it another way: technical

This is the same mathematics as inverse-variance weighting of two measurements (week 16). In Bayesian language the prior plays the role of the first measurement.

Explain it another way: mathematical

μ₀ = 20, σ₀ = 3, z = 24, σ = 2: K = 9/13 ≈ 0.692, μ₁ ≈ 22.77, σ₁² = 4 × 9/13 = 36/13, σ₁ ≈ 1.66.

Explain it another way: applied

Spacecraft orbit determination folds each new radio-tracking pass into the existing orbit estimate this way (in many dimensions): the covariance shrinks with every pass.

Derivation: Product of two Gaussians
  1. Prior ∝ exp(−(x − μ₀)²/(2σ₀²)); likelihood ∝ exp(−(z − x)²/(2σ²)).

  2. Posterior ∝ exp(−½[(x − μ₀)²/σ₀² + (x − z)²/σ²]). The exponent is quadratic in x, so the posterior is Gaussian.

  3. Collect x² terms: coefficient 1/σ₀² + 1/σ² = 1/σ₁². So 1/σ₁² = 1/σ₀² + 1/σ²: precisions add.

  4. Collect x terms: μ₁/σ₁² = μ₀/σ₀² + z/σ². So μ₁ = σ₁²(μ₀/σ₀² + z/σ²).

  5. Rewrite with K = σ₀²/(σ₀² + σ²): μ₁ = μ₀ + K(z − μ₀), σ₁² = (1 − K)σ₀². This is exactly the Kalman update.

Try these examples

Example 1

Prior N(100, 4²), measurement 106 with σ = 4. Posterior?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Prior σ₀ = 4 m, measurement σ = 3 m. What is the posterior σ, in m?

Answer: m

2. Prior belief about a crater's distance: normal, mean 10 m, σ₀ = 6 m. A lidar measurement reads z = 6 m with σ = 1 m. What is the posterior mean, in metres?

Answer: m

3. If the measurement is far noisier than the prior (σ ≫ σ₀), the update…

  • Barely moves the estimate
  • Jumps to the measurement
  • Doubles the variance
  • Is undefined

4. Prior variance 6 m², measurement variance 2 m². What is K?

Answer:

Apply it

A rover's prior on a landmark distance is N(15, 2²). Three independent lidar readings arrive: 16.1, 15.7, 16.4 m, each σ = 1 m. Update one at a time, then all at once using their mean (σ = 1/√3). Show both routes agree.

Reflect

What would go wrong if the lidar actually had σ = 4 m but your filter believed σ = 1 m?

Week 14: State-space models and orbits

This week you will

State-space form: x[k+1] = A·x[k] + B·u[k] + w[k]

To predict where a lander will be in one second, what is the smallest set of numbers you need to know right now?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Every estimator from here on needs a model of how the state moves between measurements. State-space form is the shared language: the same A and B matrices describe a rover, a lander or a satellite, and the noise term w is where the filter's Q will come from.

Goals

Predict

A lander at position 2 m, velocity 1 m/s, thrust acceleration 0.4 m/s², time step 0.5 s. Next position?

  1. 2.5 m
  2. 2.55 m
  3. 2.7 m
  4. 3.0 m

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the Code Lab, write A = [[1, Δt], [0, 1]] and B = [Δt²/2, Δt] for Δt = 0.5 s. Step a lander from p = 2 m, v = 1 m/s for 10 steps with u = 0.4 m/s², then add process noise w with σ = 0.05 on each state and run it 5 times. Plot the spread of final positions.

What the interactive shows, in words

The Code Lab activity is a matrix-stepping exercise that can be done on paper: ten steps of p ← p + 0.5v + 0.125u, v ← v + 0.5u, starting at p = 2, v = 1, u = 0.4.

Understand

What is a state?

The state x[k] is a vector holding just enough to predict the future given the inputs: for a moving body, position and velocity; for a heater, temperature. Inputs u[k] are what we command (thrust, wheel speed). Outputs y[k] = C·x[k] + v[k] are what sensors see, with measurement noise v.

The sampled model

x[k+1] = A·x[k] + B·u[k] + w[k]. A says how the state evolves on its own, B how inputs push it, and w is process noise: unmodelled disturbances such as wheel slip or a gust. For constant-acceleration motion over Δt, A = [[1, Δt], [0, 1]], B = [Δt²/2, Δt]ᵀ.

Closed loop and stability

With state feedback u = −K·x, the loop becomes x[k+1] = (A − BK)·x[k]. A discrete-time linear system is stable when every eigenvalue λ of its matrix has |λ| < 1: each step multiplies the modes by λ, so they shrink. |λ| = 1 is marginal, |λ| > 1 grows without bound.

Explain it another way: intuitive

The state is the system's memory. Knowing where the lander is and how fast it is going, you can roll the clock forward one tick at a time, nudging it with each command.

Explain it another way: technical

Continuous models ẋ = F·x + G·u discretise exactly as A = e^{FΔt}, B = ∫₀^Δt e^{Fτ}dτ·G under zero-order hold. For the double integrator this gives the A and B above exactly.

Explain it another way: mathematical

Eigenvalues of A = [[0.9, 0.1], [0, 0.8]] are 0.9 and 0.8 (upper triangular): stable. Each step the slow mode shrinks by 10%: after 22 steps it is about 10% of its start (0.9²² ≈ 0.098).

Explain it another way: applied

A Mars lander's guidance runs exactly this kind of model many times a second, predicting position and velocity from accelerometer-measured thrust and correcting with radar altimeter readings.

Try these examples

Example 1

x = [p; v] = [10; −2], Δt = 1 s, u = 0.5 m/s². Find x[k+1].

The worked solution is in the online lesson.

Example 2

Is x[k+1] = [[1.1, 0], [0, 0.5]]·x[k] stable?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A lander's state is x = [position; velocity] with x_{k+1} = A·x_k + B·u_k, A = [[1, Δt], [0, 1]], B = [Δt²/2; Δt], Δt = 0.5 s. Now position = 0 m, velocity = 1 m/s and thrust acceleration u = 1 m/s². What is the next position, in m?

Answer: m

2. Which discrete-time matrix is stable?

  • [[0.9, 0.2], [0, 0.95]]
  • [[1, 0.1], [0, 1]]
  • [[1.05, 0], [0, 0.3]]
  • [[0.5, 2], [0, 1.2]]

3. With A = [[1, Δt], [0, 1]], B = [Δt²/2; Δt], Δt = 0.2 s, v = 3 m/s and u = −5 m/s², what is the next velocity, in m/s?

Answer: m/s

4. In x[k+1] = A·x[k] + B·u[k] + w[k], what does w represent for a rover?

  • Random disturbances the model does not capture, such as wheel slip
  • Sensor noise in the camera
  • The commanded wheel speed
  • A known constant bias

Apply it

Add a third state, a constant accelerometer bias b, so the true acceleration is u − b. Write the new 3 × 3 A and the 3 × 1 B. Which state can no sensor that measures position alone ever see directly, and how could a filter still estimate it?

Reflect

Why does a filter need a model of the dynamics at all, rather than just averaging measurements?

Second-order systems as two-state models

A rover's suspension bounces after every rock. One second-order equation, or two first-order ones: which can a computer step forward?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Most physical systems are second order: springs, pendulums, suspensions, attitude dynamics. Turning them into two-state form lets you simulate them, and lets a Kalman filter estimate the velocity you never directly measure.

Goals

Predict

You simulate an undamped spring with forward Euler and a fairly large time step. What happens to the oscillation amplitude?

  1. Stays constant
  2. Slowly grows
  3. Slowly shrinks
  4. Stops immediately

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the Robotics Workbench (or Code Lab), model one wheel's suspension: m = 1 kg, k = 4 N/m, c = 1 N·s/m. Build A = [[1, Δt], [−kΔt/m, 1 − cΔt/m]] for Δt = 0.1 s, release it from x = 0.1 m, and step it 100 times. Then set c = 0 and watch forward Euler pump energy in.

What the interactive shows, in words

The simulation can be followed as a table of x and v at each step; the key result (|λ| ≈ 0.970 with damping, growth with c = 0) is stated in the text.

Understand

Two states from one equation

Choose x₁ = x (position) and x₂ = ẋ (velocity). Then ẋ₁ = x₂ and ẋ₂ = (u − c·x₂ − k·x₁)/m. In matrix form ẋ = F·x + G·u with F = [[0, 1], [−k/m, −c/m]] and G = [0, 1/m]ᵀ.

Discretise

Forward Euler: x[k+1] = x[k] + Δt·(F·x[k] + G·u[k]), so A = I + Δt·F and B = Δt·G. For m = 1, k = 4, c = 1, Δt = 0.1: A = [[1, 0.1], [−0.4, 0.9]], B = [0, 0.1]ᵀ. Its eigenvalues are complex with |λ| = √det(A) = √0.94 ≈ 0.970: a decaying oscillation.

Time step matters

The continuous system is stable for any c > 0, but the discrete model can disagree if Δt is too large. Smaller steps, or better integrators (semi-implicit Euler, Runge–Kutta, or the exact matrix exponential), keep the simulation faithful. Always check |λ| of the A you actually run.

Explain it another way: intuitive

Position alone cannot tell you where a bouncing wheel is going next: it could be on its way up or on its way down. Add velocity and the future is determined.

Explain it another way: technical

Natural frequency ωₙ = √(k/m) = 2 rad/s, damping ratio ζ = c/(2√(km)) = 0.25. Continuous poles s = −ζωₙ ± jωₙ√(1 − ζ²) = −0.5 ± 1.94j.

Explain it another way: mathematical

For a 2 × 2 matrix with complex eigenvalues, |λ|² = det(A). det [[1, 0.1], [−0.4, 0.9]] = 0.9 + 0.04 = 0.94. With c = 0: det = 1 + 0.04 = 1.04 > 1: Euler makes the frictionless spring grow.

Explain it another way: applied

Spacecraft attitude about one axis is a two-state model (angle, rate) driven by reaction-wheel torque. Star trackers measure the angle; gyros measure the rate; the filter needs both states.

Try these examples

Example 1

m = 2 kg, k = 8 N/m, c = 2 N·s/m, Δt = 0.05 s. Write A.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A = [[1, 0.1], [−0.4, 0.9]] has complex eigenvalues. What is |λ| (to 3 decimal places)?

Answer:

2. For m = 0.5 kg, k = 2 N/m, c = 0.5 N·s/m and Δt = 0.1 s, what is the bottom-right entry of the Euler A matrix, 1 − cΔt/m?

Answer:

3. A lander's state is x = [position; velocity] with x_{k+1} = A·x_k + B·u_k, A = [[1, Δt], [0, 1]], B = [Δt²/2; Δt], Δt = 0.5 s. Now position = 5 m, velocity = 1 m/s and thrust acceleration u = 0.5 m/s². What is the next velocity, in m/s?

Answer: m/s

4. Why does a Kalman filter for a suspension need the velocity state even if only position is measured?

  • Position alone cannot predict the next position; velocity carries the motion between samples
  • Velocity is always measured too
  • Two states make the filter run faster
  • It does not need it

Apply it

Find the largest Δt for which forward Euler keeps the m = 1, k = 4, c = 1 suspension stable (solve det(A) < 1 with A = I + ΔtF). Check your answer by simulation.

Reflect

What is one system in your life that needs two states to predict, and what are they?

Orbits from gravity: speed, period and Kepler's third law

The International Space Station is falling all the time, at about 7.7 km/s sideways. Why doesn't it hit the ground?

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Before a rover can navigate Mars, its spacecraft must get there, and an orbiter must relay its messages. Orbital speed and period set everything from relay pass times to how long a navigation fix stays useful. All of it starts with one force balance.

Goals

Predict

A satellite is moved from 400 km to 1,600 km altitude above Earth. Its orbital speed…

  1. Increases
  2. Decreases
  3. Stays the same
  4. Becomes zero

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Around Earth, find the altitude where the period is about 92 minutes (the ISS), then about 24 hours. Note the speed at each. Switch to Mars and the Moon at 400 km: compare speeds. Check that T²/r³ stays the same for every orbit around one body.

What the interactive shows, in words

The orbit explorer draws the planet and a circular orbit; the readout states radius, speed, period, escape speed and the Kepler constant T²/r³ in text for every setting.

Understand

Radius, not altitude

Every formula uses r measured from the centre of the body. Earth's radius is about 6,371 km, so the ISS at 400 km altitude has r = 6,771 km and v = √(3.986 × 10¹⁴ / 6.771 × 10⁶) ≈ 7.67 km/s, T ≈ 92.4 min. Forgetting the radius is the most common orbital error.

Higher is slower

Speed falls as 1/√r and period grows as r^1.5. At r ≈ 42,164 km the period equals one sidereal day (86,164 s): a geostationary orbit hangs over one longitude, ideal for communications. The Moon, at about 384,000 km, takes about 27 days.

Mass cancels

The satellite's mass drops out: a bolt and a space station in the same orbit move together. That is why astronauts float: they and their station fall at the same rate. Different planets differ only through μ: Mars's μ ≈ 4.28 × 10¹³ m³/s² is about 11% of Earth's.

Explain it another way: intuitive

Throw a ball sideways and it curves down to the ground. Throw it faster and it lands further away. Throw it so fast that the ground curves away as fast as the ball falls, and it never lands: that is an orbit.

Explain it another way: technical

Specific orbital energy ε = v²/2 − μ/r = −μ/(2a). For a circle, kinetic energy is half the magnitude of potential energy (virial theorem), which is why raising an orbit both costs energy and slows you down.

Explain it another way: mathematical

Low Mars orbit at 400 km: r = 3,789.5 km, v = √(4.283 × 10¹³ / 3.7895 × 10⁶) ≈ 3.36 km/s, T ≈ 118 min. Kepler scaling: quadrupling r multiplies T by 4^1.5 = 8.

Explain it another way: applied

Mars relay orbiters pass over a rover only a few times per sol, for minutes each: their periods (about two hours) and the planet's rotation set when a rover can upload data, which shapes its daily plan.

Derivation: Circular orbital speed and Kepler's third law
  1. Gravity on a satellite of mass m at distance r from the centre: F = GMm/r².

  2. Circular motion at speed v needs a centripetal force F = mv²/r towards the centre.

  3. Gravity supplies it exactly: GMm/r² = mv²/r. The mass m cancels.

  4. So v = √(GM/r). Writing μ = GM (Earth: μ ≈ 3.986 × 10¹⁴ m³/s²).

  5. Period T = 2πr/v = 2π√(r³/μ), so T² = (4π²/μ)·r³: Kepler's third law, T² ∝ r³ (and for ellipses, ∝ a³ with semi-major axis a).

Try these examples

Example 1

Find the speed and period of a circular orbit 400 km above Earth (R = 6,371 km, μ = 3.986 × 10¹⁴ m³/s²).

The worked solution is in the online lesson.

Example 2

What radius gives a period of 86,164 s around Earth?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A satellite is in a circular orbit 300 km above Earth (radius 6371 km, GM = 3.986e+14 m³/s²). What is its orbital speed, in km/s?

Answer: km/s

2. What is the period of a circular orbit 400 km above Earth (radius 6371 km, GM = 3.986e14 m³/s²), in minutes?

Answer: min

3. A probe orbits a moon with period 100 minutes. A second probe orbits the same moon with an orbit radius 3 times larger. Using T² ∝ a³, what is its period, in minutes?

Answer: min

4. A 1 kg cubesat and a 400 t station share a circular orbit. Which moves faster?

  • Neither: same speed
  • The cubesat
  • The station
  • It depends on their shapes

5. A student computes the ISS speed using r = 400 km. Their answer will be…

  • About 4× too large
  • Correct
  • About 4× too small
  • About 30% too small

Apply it

A Mars relay orbiter has a period of 2 hours. Find its orbital radius and altitude (μ_Mars = 4.283 × 10¹³ m³/s², R = 3,390 km), then estimate roughly how many minutes it is above a rover's horizon on a single overhead pass, stating your simplifying assumptions.

Reflect

Why does the satellite's own mass not appear anywhere in v = √(GM/r)?

Week 15: State estimation

This week you will

Dead reckoning and why it drifts

Count every wheel turn perfectly and you still end up metres from where you think you are. Where does the error come from, and how fast does it grow?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Dead reckoning is always available: no landmark, no radio, no sky needed. It is also always wrong, in a predictable way. Knowing how fast it drifts tells a planner how often the rover must stop for an absolute fix.

Goals

Predict

A rover's heading is off by a constant 1°. After driving 500 m, roughly how far sideways is it from its intended track?

  1. About 0.5 m
  2. About 9 m
  3. About 50 m
  4. About 1 m

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Start with only 3% slip bias and no heading drift: double the steps and check the error doubles. Now set slip to 0 and heading drift to 0.1° per step: double the steps and watch the error roughly quadruple. Finally use noise only, and compare how slowly random error grows.

What the interactive shows, in words

The drift rover draws the straight true track and the dead-reckoned track; the readout states the final error and the bias-only predictions for along-track and cross-track error.

Understand

Integration accumulates

Dead reckoning adds up measured steps: x[k] = x[k−1] + d[k]·cos θ[k], y[k] = y[k−1] + d[k]·sin θ[k]. Any error in d or θ is added in and never removed. The estimate's uncertainty can only grow until an absolute measurement arrives.

Three growth laws

A scale bias (wheels over-reading by fraction s) gives along-track error s·d: linear in distance. A constant heading error θ₀ gives cross-track error d·sin θ₀: also linear. A heading drift rate b (gyro bias) makes the heading error grow with time, so cross-track error grows like ½·v·b·t². Independent random step errors grow only like √n.

Living with drift

The cure is not a perfect wheel but an occasional absolute fix: a landmark, a sun sensor, an orbital image. A drift model tells you the spacing: if heading drift adds 1 m of error every 100 m and the corridor allows 2 m, fix at least every 200 m, with margin.

Explain it another way: intuitive

Walk across a field with your eyes closed, counting steps. You will be roughly the right distance away but drift off to one side, and the further you go, the faster you drift.

Explain it another way: technical

With heading error θ(t) = θ₀ + b·t, cross-track error y(t) = ∫v·sin θ(t)dt ≈ v(θ₀t + ½bt²) for small angles. Bias terms dominate long drives; noise terms dominate short ones.

Explain it another way: mathematical

Gyro bias 0.01 °/s = 1.745 × 10⁻⁴ rad/s, speed 5 cm/s, t = 1,000 s: y ≈ ½ × 0.05 × 1.745 × 10⁻⁴ × 10⁶ ≈ 4.4 m after just 50 m of driving.

Explain it another way: applied

Mars rovers measure slip by comparing wheel odometry with visual odometry (tracking features between camera frames). On steep sandy slopes slip can be large, so rovers switch to visual odometry more often there.

Try these examples

Example 1

Wheels over-read by 3%. Distance 100 m. Along-track error?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Odometry over-reads distance by 4% because of slip. After 250 m, what is the along-track error, in metres?

Answer: m

2. Wheel odometry over-reads distance by 8% because of slip. The rover drives 100 m. What is the along-track position error, in metres?

Answer: m

3. With a constant gyro DRIFT RATE (heading error growing steadily), doubling the drive time at constant speed makes the cross-track error…

  • About 4× larger
  • 2× larger
  • √2× larger
  • Unchanged

4. Each of 100 steps has an independent random length error with σ = 2 cm and no bias. What is the σ of the total along-track error, in cm?

Answer: cm

Apply it

Using the drift rover, find the largest step count for which the final error stays under 2 m with 3% slip and 0.05° per step heading drift. That is your fix spacing. Then halve the gyro drift: how much further can the rover go between fixes?

Reflect

Why is a slowly growing bias more dangerous than a large but random error?

Aerospace sensing: IMUs, star trackers, sun sensors and radio

A spacecraft coasting between planets has no road, no GPS and no landmarks. How does it know which way it is pointing and where it is?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Every navigation system pairs fast, drifting sensors with slow, absolute ones. On spacecraft the cast changes (stars instead of landmarks, radio instead of GPS) but the logic of fusion is exactly what you have been building.

Goals

Predict

What does an accelerometer on a spacecraft coasting in orbit read (engines off)?

  1. About 9.8 m/s²
  2. About zero
  3. The orbital speed
  4. The centripetal acceleration v²/r

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the fusion lab, treat odometry as a gyro-integrated attitude (relative, biased) and the camera as a star tracker (absolute, but blinded at times). Set a bias and a high dropout rate: watch the estimate drift during blackouts and snap back on each fix. Record how the error depends on blackout length.

What the interactive shows, in words

The fusion lab plays the role of a gyro (relative, biased) and a star tracker (absolute, sometimes blinded). The key observation, error growing during blackouts and dropping at each fix, is stated in the instruction and readable from the lab's error readout.

Understand

Inertial sensors (relative)

A gyroscope measures angular rate; integrating gives attitude change, with errors from bias (drift in °/h) and angle random walk. An accelerometer measures specific force (non-gravitational acceleration); integrating twice gives position change, so a tiny bias grows like t². Together they form an IMU: fast (hundreds of Hz) and always on, but drifting.

Attitude references (absolute)

A star tracker photographs the sky and matches star patterns to a catalogue, giving full attitude to a few arcseconds; it is slower and is blinded by the Sun, Moon or a bright planet near its view. A sun sensor gives the Sun's direction, coarse to fine, cheaply and robustly, but only two axes and only in sunlight.

Radio tracking (absolute range)

Ground stations send a signal that the spacecraft returns. Range = c·Δt/2 from the two-way light time Δt; a 10 ns timing error is 1.5 m. Doppler shift gives velocity along the line of sight. Range and Doppler fix only the line-of-sight direction well, so orbit determination combines passes over time, sometimes from two stations.

Explain it another way: intuitive

The IMU is your sense of balance: instant but easily fooled. Star trackers and sun sensors are looking at the horizon: slower but honest. Radio is someone far away shouting how far you are.

Explain it another way: technical

Gyro and star tracker are fused (often in a multiplicative Kalman filter) so the filter estimates gyro bias as an extra state; between star fixes, attitude propagates on bias-corrected gyro rates.

Explain it another way: mathematical

Two-way light time to a probe 1.5 × 10¹¹ m away: Δt = 2d/c = 1,000 s. Range resolution from 1 ns timing: c × 10⁻⁹/2 = 0.15 m, astonishing precision at 150 million km.

Explain it another way: applied

Mars rovers use an IMU for attitude while driving and sun sensing or sky images to correct heading, plus visual odometry and orbital map matching for position: the same relative/absolute pairing on the ground.

Try these examples

Example 1

A ranging signal returns 1,200 s after it was sent. How far is the spacecraft? (c = 3 × 10⁸ m/s)

The worked solution is in the online lesson.

Example 2

A gyro has bias 0.01 °/h. With no star fix for 10 hours, how large is the attitude error?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Which pair is (relative sensor, absolute sensor)?

  • Gyroscope, star tracker
  • Star tracker, gyroscope
  • Sun sensor, star tracker
  • Accelerometer, gyroscope

2. A timing error of 4 ns in two-way radio ranging gives what range error, in metres? (c = 3 × 10⁸ m/s)

Answer: m

3. Why can't a spacecraft's IMU alone track its position over a months-long cruise?

  • Accelerometer bias integrates twice, growing like t², and gravity is not sensed at all
  • IMUs only work on Earth
  • Gyros measure position directly
  • Accelerometers saturate in space

4. An accelerometer has an uncorrected bias of 10⁻⁴ m/s². After 1,000 s, how large is the resulting position error, in metres?

Answer: m

5. Radio ranging gives a spacecraft's distance with σ₁ = 4 km and an optical navigation fix gives it with σ₂ = 2 km (independent). What is the σ of the optimally fused distance, in km?

Answer: km

Apply it

Design a sensor suite for a small Mars orbiter: for attitude and for position, pick one relative and one absolute source, state an update rate and one failure mode for each, and say what the filter should do when the absolute source is unavailable.

Reflect

Which of these sensors has an analogue on a ground rover, and which have none?

The predict–update cycle

Drive a metre: your uncertainty grows. See a landmark: it shrinks. Repeat forever. That rhythm is the whole idea of a filter.

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

This is the loop running inside every rover, drone and phone that knows where it is. Once you can step it by hand, the Kalman filter stops being a formula and becomes a story: predict, get surprised, correct by the right amount.

Goals

Predict

During a dust storm the camera fix is unavailable for 5 steps in a row. What happens to the filter's variance P?

  1. It grows by Q every step
  2. It stays constant
  3. It shrinks
  4. It resets to zero

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Step predict → update ten times in clear skies and watch the band settle to a steady width. Reset, switch on dust, and step again: note how wide the band gets during the gaps. Check after each update that the green truth line stays inside the ±2σ band most of the time.

What the interactive shows, in words

The Kalman stepper plots truth, landmark fixes and the estimate with a ±2σ band over 20 steps. Each button press updates a text readout with the estimate, σ, truth, error and gain.

Understand

Predict

Push the estimate through the model: x⁻ = x + u (here, the commanded move) and P⁻ = P + Q. Q is the variance the model adds each step: wheel slip, gusts, anything unmodelled. Prediction always increases uncertainty.

Update

When a measurement z with variance R arrives, compute the innovation z − x⁻, the gain K = P⁻/(P⁻ + R), then x = x⁻ + K(z − x⁻) and P = (1 − K)P⁻. This is the conjugate normal update from week 13 with the prediction as prior.

Checking a filter honestly

In simulation you know the truth, so measure RMSE of x − x_true. Also check consistency: about 95% of errors should fall within ±2√P. If the truth often leaves the band, the filter is overconfident (Q or R too small); if it never comes close to the edge, it is too cautious.

Explain it another way: intuitive

You are walking in fog. Each step you are a little less sure where you are. When a lamppost appears you correct, more if you trust your eyes, less if the fog is thick.

Explain it another way: technical

With constant Q and R the variance converges to a steady state: prior variance P⁻∞ = (Q + √(Q² + 4QR))/2, giving a constant steady-state gain. Many embedded filters just use that constant gain.

Explain it another way: mathematical

x = 0, P = 1, u = 1, Q = 0.25: x⁻ = 1, P⁻ = 1.25. z = 1.6, R = 0.5: K = 1.25/1.75 ≈ 0.714, x = 1 + 0.714 × 0.6 ≈ 1.43, P = 0.286 × 1.25 ≈ 0.357.

Explain it another way: applied

BUILD 006's rover uses exactly this cycle: odometry predicts, a landmark photo updates. Its Level 2 numbers, odometry σ = 1 m meeting a camera σ = 0.5 m, give K = 0.8 and a fused σ ≈ 0.45 m.

Try these examples

Example 1

x = 0, P = 1 m². Drive u = 1 m with Q = 0.25 m². Fix z = 1.6 m with R = 0.5 m². Predict and update.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A rover's estimate is x = 10 m with variance P = 1 m². It drives u = 1 m (process noise Q = 2 m²), then a landmark fix reads z = 10 m with R = 3 m². After predict and update, what is the new estimate x, in m?

Answer: m

2. A filter has P = 0.4 m² after an update. Q = 0.3 m² per step. With no fixes for 6 steps, what is P, in m²?

Answer: m²

3. In simulation, the true position leaves the filter's ±2σ band on 40% of steps. The most likely problem is…

  • Q and/or R are set too small: the filter is overconfident
  • Q and R are too large
  • The filter is working perfectly
  • The truth is wrong

4. After predicting, a 1-D Kalman filter's variance is P = 1 m². The camera measurement variance is R = 2 m². What is the Kalman gain K?

Answer:

Apply it

In the stepper, run 20 steps in dusty conditions with Q = 0.2 and R = 1. Record the error and √P at each step and compute the fraction of steps where |error| < 2√P. Repeat with Q set ten times too small (in your head, the filter's Q, not the truth's). What changes?

Reflect

What would you tell a teammate who wants to set R = 0 'because the camera is really good'?

Week 16: Sensor fusion and orbit transfers

This week you will

Inverse-variance weighting

Two sensors measure the same distance. One is twice as precise. Should you trust it twice as much? Four times? All the way?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

This one formula is the foundation of sensor fusion: GPS with odometry, star tracker with gyro, camera with lidar. It says how much to trust each source and promises a result better than the best single sensor, if its assumptions hold.

Goals

Predict

Sensor A has σ = 1 m, sensor B has σ = 2 m. What weight should A get in the optimal blend?

  1. 2/3
  2. 4/5
  3. 1/2
  4. 1 (ignore B)

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Set σ₁ = 1, σ₂ = 2. Drag your weight w from 0 to 1 and watch the lower curve: the blend's σ dips to a minimum. Find it by hand, then press 'snap' to check. Repeat with equal σ's: where is the minimum now, and what is the fused σ?

What the interactive shows, in words

The fusion diagram plots both sensor curves, your blend and the optimal fusion, plus a curve of blend σ against weight with its minimum marked. The readout gives the optimal weight, fused value and σ, and how far your chosen weight is from optimal.

Understand

The recipe

x̂ = (z₁/σ₁² + z₂/σ₂²)/(1/σ₁² + 1/σ₂²) and σ_f = 1/√(1/σ₁² + 1/σ₂²). The fused value sits between the readings, closer to the more precise one; the fused σ is smaller than the smaller σ. Two equal sensors give σ/√2.

The fine print

It assumes both readings are unbiased, independent and have correctly known σ. A biased sensor drags the fused value with full confidence. Correlated errors (two cameras with the same calibration fault) give less improvement than the formula promises.

A consistency check

If the readings disagree by much more than √(σ₁² + σ₂²), something is wrong: a fault, a bias, a wrong σ. Real systems test the difference before fusing and reject outliers. In Kalman language this is innovation gating.

Explain it another way: intuitive

A friend with sharp eyes and a friend with blurry eyes both guess the distance to a tree. You lean towards sharp-eyes, but blurry-eyes still adds a little information, so together they beat either one.

Explain it another way: technical

This is the minimum-variance unbiased linear estimator, and for Gaussian errors also the maximum-likelihood estimate. It is identical to the conjugate normal update with one reading as prior.

Explain it another way: mathematical

z₁ = 10, σ₁ = 3; z₂ = 13, σ₂ = 2: weights 1/9 and 1/4, w₁ = 4/13 ≈ 0.31. x̂ = (10/9 + 13/4)/(13/36) ≈ 12.08, σ_f = √(36/13) ≈ 1.66.

Explain it another way: applied

Deep-space orbit determination fuses radio range, Doppler and optical images of the target body; each pass is weighted by its accuracy, so a few very precise range points can outweigh many noisy ones.

Derivation: Why inverse-variance weights are optimal
  1. Blend two independent unbiased readings: x̂ = w·z₁ + (1 − w)·z₂. It is unbiased for any w.

  2. Its variance is V(w) = w²σ₁² + (1 − w)²σ₂² (no cross term, by independence).

  3. Minimise: dV/dw = 2wσ₁² − 2(1 − w)σ₂² = 0 ⇒ w = σ₂²/(σ₁² + σ₂²) = (1/σ₁²)/(1/σ₁² + 1/σ₂²).

  4. d²V/dw² = 2(σ₁² + σ₂²) > 0, so this is a minimum.

  5. Substitute back: V_min = σ₁²σ₂²/(σ₁² + σ₂²), i.e. 1/σ_f² = 1/σ₁² + 1/σ₂². For n sensors, weights ∝ 1/σᵢ² and precisions add.

Try these examples

Example 1

Readings 10 (σ = 3) and 13 (σ = 2). Fuse them.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Sensor σ's are 2 m and 4 m. What weight does the 2 m sensor get?

Answer:

2. A sun sensor puts the rover's heading at z₁ = 10° with σ₁ = 1°, and a gyro-integrated heading reads z₂ = 13° with σ₂ = 1° (independent). What is the inverse-variance fused heading, in degrees?

Answer: °

3. Radio ranging gives a spacecraft's distance with σ₁ = 2 km and an optical navigation fix gives it with σ₂ = 3 km (independent). What is the σ of the optimally fused distance, in km?

Answer: km

4. Sensor B has a hidden +5 m bias but claims σ = 0.5 m; sensor A is unbiased with σ = 2 m. The fused estimate will be…

  • Close to B, and wrong by nearly 5 m, with a small reported σ
  • Close to the truth
  • Exactly halfway
  • Rejected automatically

5. Three independent sensors each have σ = 3 cm. What is the σ of their optimal fusion, in cm?

Answer: cm

Apply it

Write a 'fuse-or-reject' rule for two range sensors: fuse if |z₁ − z₂| < 3√(σ₁² + σ₂²), otherwise flag a fault. Test it in the diagram with σ's of 1 and 2 m: what readings trigger the flag?

Reflect

Which assumption of inverse-variance weighting is hardest to check on a real rover, and why?

The complementary filter

A gyro is smooth but drifts. An accelerometer never drifts but jitters. Could you keep the best half of each?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

The complementary filter is fusion in one line of code. It runs on hobby drones, phones and balance robots because it is cheap, intuitive and robust, and it shows the frequency-domain view of fusion that the Kalman filter hides.

Goals

Predict

In θ = 0.98(θ + ω·Δt) + 0.02·θ_acc, what does the 0.02 path mainly correct?

  1. The gyro's slow drift
  2. The accelerometer's jitter
  3. Both equally
  4. Neither: it is just rounding

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the fusion lab choose the complementary filter. With a large odometry bias, sweep α from 0.5 to 0.99. Record the RMSE at each α. Where is the best α? Then switch to Kalman with the same settings and compare: which estimates (and removes) the bias?

What the interactive shows, in words

The fusion lab's RMSE readout gives the numbers for each α; the expected trend, a best α in the middle with errors rising at both extremes, is described in the instruction.

Understand

Two paths that add to one

θ[k] = α(θ[k−1] + ω·Δt) + (1 − α)·θ_acc. The gyro path (integrate rate) is effectively high-passed: good for fast changes. The accelerometer path is low-passed: good for the slow, long-term level. Because the two filters add to exactly one, the true signal passes through unchanged.

Choosing α

The crossover time constant is τ = αΔt/(1 − α). With α = 0.98 and Δt = 0.01 s, τ = 0.49 s: changes faster than about half a second come from the gyro, slower ones from the accelerometer. Pick τ longer than the accelerometer's jitter but shorter than the time the gyro takes to drift noticeably.

Complementary versus Kalman

The complementary filter uses a fixed blend. A Kalman filter computes its gain from Q and R and can add the gyro bias as a state and estimate it, so the drift is removed rather than just pulled back. In steady state, a scalar Kalman filter with constant gain behaves much like a well-tuned complementary filter.

Explain it another way: intuitive

Let the gyro steer moment to moment, while the accelerometer gently tugs the answer back towards 'down' over a second or so.

Explain it another way: technical

In the Laplace domain: θ̂ = [τs/(τs + 1)]·(ω/s) + [1/(τs + 1)]·θ_acc. The two transfer functions sum to 1. With a constant gyro bias b, the steady-state error is b·τ: smaller τ, less bias error but more accelerometer noise.

Explain it another way: mathematical

θ_prev = 5°, ω = 3 °/s, Δt = 0.02 s, θ_acc = 5.5°, α = 0.95: gyro step 5.06°, blend 0.95 × 5.06 + 0.05 × 5.5 = 5.082°.

Explain it another way: applied

Rover and drone attitude estimators often start as complementary filters, then grow into Kalman filters when bias estimation or extra sensors (magnetometer, sun sensor) are needed.

Try these examples

Example 1

α = 0.98, Δt = 0.01 s. Time constant? Steady-state tilt error from a 0.5 °/s gyro bias?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. A complementary filter estimates tilt: θ = α(θ_prev + ω·Δt) + (1 − α)·θ_acc. With θ_prev = 5°, gyro rate ω = -4°/s, Δt = 0.05 s, accelerometer tilt θ_acc = 6.5° and α = 0.98, what is the new θ, in degrees?

Answer: °

2. A complementary filter runs at Δt = 0.005 s with α = 0.99. What is its time constant τ, in seconds?

Answer: s

3. What happens if α = 1?

  • Pure gyro integration: drift is never corrected
  • Pure accelerometer: very noisy
  • Perfect fusion
  • The filter stops updating

4. With τ = 2 s and an uncorrected gyro bias of 0.3 °/s, what is the approximate steady-state tilt error, in degrees?

Answer: °

Apply it

Using the fusion lab, find the α that minimises RMSE for two different odometry bias settings. Explain, with τ = αΔt/(1 − α), why the best α moves the way it does.

Reflect

When would you choose a complementary filter over a Kalman filter on a real robot?

Escape speed and Hohmann transfers

To get from low orbit to geostationary orbit you burn your engine twice, and in between you coast for more than five hours on half an ellipse. Why that path?

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Δv, the total change of speed a spacecraft can make, is the budget every mission is designed around. The Hohmann transfer is the reference manoeuvre that sets the minimum (for two impulsive burns between coplanar circular orbits), and the first number a Mars mission planner writes down.

Goals

Predict

Escape speed from a given radius is how many times the circular orbital speed there?

  1. √2 ≈ 1.41
  2. 2
  3. 1.5
  4. The same

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Around Earth, plan 300 km → 35,786 km (geostationary). Read both burns and the coast time. Then try a target of 384,000 km (the Moon's distance). Switch to 'around the Sun' and plan Earth → Mars: how long is the coast, and how does it compare with real Mars cruises of about 7 months?

What the interactive shows, in words

The Hohmann planner draws the start orbit, target orbit and the half-ellipse transfer. The readout states both burns, the total Δv, the coast time and the margin against your Δv budget.

Understand

Escape speed

Energy per unit mass: ε = v²/2 − μ/r. To escape, ε ≥ 0, so v_esc = √(2μ/r). From Earth's surface (ignoring air) that is about 11.2 km/s. It is √2 times the circular speed at the same radius.

Vis-viva and the transfer ellipse

On any orbit with semi-major axis a, v² = μ(2/r − 1/a). A Hohmann transfer uses an ellipse that just touches both circles: a = (r₁ + r₂)/2. Burn 1 at r₁: Δv₁ = √(μ(2/r₁ − 1/a)) − √(μ/r₁). Burn 2 at r₂: Δv₂ = √(μ/r₂) − √(μ(2/r₂ − 1/a)).

Time and trade-offs

The coast is half the ellipse: t = π√(a³/μ). LEO (300 km) to geostationary: Δv ≈ 2.43 + 1.47 = 3.90 km/s, t ≈ 5.3 h. Earth to Mars (heliocentric, circular coplanar idealisation): about 2.95 + 2.65 ≈ 5.60 km/s and about 259 days, and the planets must be correctly aligned at departure, which happens about every 26 months.

Explain it another way: intuitive

Speed up a little at the bottom and you swing higher on the other side. When you get there you are moving too slowly to stay, so you speed up again to settle into the high circle.

Explain it another way: technical

Hohmann is Δv-optimal among two-impulse transfers between coplanar circles for radius ratios below about 11.94; above that, bi-elliptic transfers can win. Real missions also escape Earth's and capture into Mars's gravity wells (patched conics), which this lesson ignores.

Explain it another way: mathematical

r₁ = 6,671 km, r₂ = 42,164 km, a = 24,417.5 km. v₁ = 7.730, v_p = 10.158 km/s ⇒ Δv₁ = 2.428. v_a = 1.607, v₂ = 3.075 km/s ⇒ Δv₂ = 1.468. Total 3.895 km/s; t = π√(a³/μ) ≈ 18,986 s ≈ 5.27 h.

Explain it another way: applied

Mission designers use the Hohmann Δv as a baseline, add margins for gravity losses, plane changes and navigation corrections, then let the rocket equation turn the Δv budget into a propellant mass.

Try these examples

Example 1

Escape speed from the surface of Mars (μ = 4.283 × 10¹³ m³/s², R = 3,390 km)?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. What is the escape speed from the surface of Mars (radius 3390 km, GM = 4.283e+13 m³/s²), in km/s?

Answer: km/s

2. Plan a Hohmann transfer from a circular orbit 200 km above Earth to one 35786 km above Earth (radius 6371 km, GM = 3.986e14 m³/s²). What is the total Δv of the two burns, in km/s?

Answer: km/s

3. A Hohmann transfer goes from r₁ = 7,000 km to r₂ = 21,000 km. What is the transfer ellipse's semi-major axis, in km?

Answer: km

4. Why is a second burn needed at the top of the transfer?

  • At apoapsis the spacecraft is slower than circular speed there, so it would fall back
  • To slow down for landing
  • To change orbital plane
  • It is optional

Apply it

In the planner, set a Δv budget of 4.0 km/s around Earth. What is the highest circular orbit you can reach from 300 km? Then explain, in one paragraph, why a Mars mission's Δv budget must include navigation correction burns on top of the Hohmann value.

Reflect

Why do missions to Mars launch only in certain windows, roughly every 26 months?

Week 17: Introductory optimal estimation

This week you will

The Kalman gain as the variance-minimising weight

Why P/(P + R)? Not a guess, not a rule of thumb: it is the only weight that makes the error as small as possible.

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

The gain is the filter's only decision: how much to believe the newest measurement. Deriving it yourself shows that the Kalman filter is just inverse-variance weighting applied again and again, with the prediction as one of the two sensors.

Goals

Predict

The prediction has variance P⁻ = 3 and the measurement R = 1. The best gain K is…

  1. 0.25
  2. 0.75
  3. 0.5
  4. 1

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Set R small (0.1) and step: K stays near 1, and the estimate jumps to every fix. Set R large (5): K is small and the estimate glides. Then fix R = 1 and step 15 times: watch K settle to a constant. That constant is the steady-state gain.

What the interactive shows, in words

The derivation is fully written in text. The stepper's readout reports the gain at every update, so the convergence to a steady gain can be followed as numbers.

Understand

Reading the gain

K → 1 when R ≪ P⁻: trust the sensor, x ≈ z. K → 0 when R ≫ P⁻: trust the prediction, ignore the reading. K is not a tuning knob you set; it is computed from the variances you believe. What you tune are Q and R.

Steady state

With constant Q and R the variance stops changing. For the random-walk model x[k+1] = x[k] + u + w, the prior variance converges to P⁻∞ = (Q + √(Q² + 4QR))/2. With Q = 0.3, R = 2: P⁻∞ ≈ 0.939, K∞ ≈ 0.319. Many embedded filters precompute this constant gain.

In more dimensions

For vector states, K = P⁻Hᵀ(HP⁻Hᵀ + R)⁻¹ and P = (I − KH)P⁻, where H maps the state to what the sensor sees. The scalar case is H = 1. The same minimum-variance argument, done with matrices, gives the same structure.

Explain it another way: intuitive

The gain is a trust dial between 'my model says' and 'my sensor says', set automatically from how unsure each one is right now.

Explain it another way: technical

For linear-Gaussian systems, the Kalman filter is the exact Bayesian posterior and the minimum-mean-square-error estimator. For non-Gaussian noise it is still the best LINEAR unbiased estimator.

Explain it another way: mathematical

Q = R = 1: P⁻∞ = (1 + √5)/2 ≈ 1.618 (the golden ratio) and K∞ = P⁻∞/(P⁻∞ + 1) ≈ 0.618.

Explain it another way: applied

Apollo's onboard navigation used a Kalman filter to fold in optical sightings of stars and landmarks; each sighting's gain depended on how uncertain the state had become since the last one.

Derivation: The scalar Kalman gain
  1. Update rule: x = x⁻ + K(z − x⁻) = (1 − K)x⁻ + Kz. Prediction error e⁻ has variance P⁻; measurement error v has variance R; they are independent.

  2. Posterior error e = (1 − K)e⁻ + K·v (the true x cancels because both terms are unbiased).

  3. Its variance: P(K) = (1 − K)²P⁻ + K²R.

  4. Minimise: dP/dK = −2(1 − K)P⁻ + 2KR = 0 ⇒ K = P⁻/(P⁻ + R).

  5. Substitute back: P = (1 − K)P⁻ = P⁻R/(P⁻ + R), i.e. 1/P = 1/P⁻ + 1/R: inverse-variance weighting, again.

Try these examples

Example 1

Q = 0.3, R = 2. Find the steady-state prior variance, gain and posterior variance.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. After predicting, a 1-D Kalman filter's variance is P = 2 m². The camera measurement variance is R = 0.25 m². What is the Kalman gain K?

Answer:

2. A random-walk filter has Q = 1 and R = 1. What is the steady-state gain K∞ (3 decimal places)?

Answer:

3. A filter is told R = 0 (a perfect sensor). What does it do at each update?

  • Sets x = z exactly and P = 0
  • Ignores the measurement
  • Averages x⁻ and z
  • Crashes

4. A rover's estimate is x = 5 m with variance P = 2 m². It drives u = 3 m (process noise Q = 2 m²), then a landmark fix reads z = 10 m with R = 1 m². After predict and update, what is the new estimate x, in m?

Answer: m

5. P⁻ = 4 m², R = 1 m². What is the posterior variance P, in m²?

Answer: m²

Apply it

In the stepper, measure the gain after 15 steps for Q = 0.2 and three values of R (0.5, 1, 2). Compare with the steady-state formula. Then explain, in one sentence each, what physically changing Q and R would mean for a rover.

Reflect

If you could improve either the camera (R) or the wheels (Q) by a factor of two, which would help the estimate more in steady state? Try both in the formula.

Tuning a two-state filter: position and bias

Your wheels lie by 1.5 cm every second, always in the same direction. Could the filter learn that lie and subtract it?

About 45 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Real sensors have biases that change slowly. Adding the bias as a state lets the filter estimate and remove it, which is how spacecraft keep gyros honest between star fixes and how the fusion lab's Kalman filter beats the complementary one.

Goals

Predict

The camera only ever measures position. Can a filter still estimate the odometry bias?

  1. Yes: the bias shows up as a steady pattern in the innovations over time
  2. No: you can only estimate what you measure
  3. Only if the rover stops
  4. Only with a second camera

Write down your guess and your reason. The reveal is in the online lesson.

Discover

In the fusion lab choose the Kalman filter and a clear nonzero odometry bias. Watch the estimated bias converge. Then raise the dropout rate: does the position error during blackouts stay small because the bias has been learned? Compare with the complementary filter on the same seed.

What the interactive shows, in words

The fusion lab reports position error and, for the Kalman filter, the estimated bias as numbers; the expected behaviour (bias converging, small error during blackouts) is described in the instruction.

Understand

Augment the state

State x = [p, b]ᵀ: position and odometry bias. Odometry reports d = Δp_true + b·Δt + noise, so the prediction is p ← p + d − b·Δt and b ← b (a random walk). In matrix form A = [[1, −Δt], [0, 1]], with the odometry reading as input, and the camera measures H = [1, 0].

Observability

A state is observable if its effect eventually appears in the measurements. The bias pushes the position prediction away from the camera fixes at a steady rate, so over several fixes the filter can separate it from random noise. During a long blackout nothing new is learned, but the learned bias keeps being subtracted.

Tuning Q and R

Start R from the sensor's measured noise. Q is harder: it encodes how much the model can be wrong per step (slip, bias wander). Q too small: sluggish, overconfident, truth leaves the ±2σ band. Q too large: jumpy, noisy estimate. Tune on simulated runs with known truth, check consistency, and never tune on the same runs you report.

Explain it another way: intuitive

If your watch gains a minute every day and you check it against the radio each morning, after a few days you know the gain and can correct for it even on days you miss the radio.

Explain it another way: technical

The pair (A, H) is observable when the matrix [H; HA] has full rank. Here [[1, 0], [1, −Δt]] has rank 2 for Δt > 0, so position and bias are both observable from position fixes.

Explain it another way: mathematical

Process noise for the bias random walk: Q_b = σ_b²Δt. A tiny Q_b says 'the bias barely changes', so the filter averages over many fixes; a larger Q_b lets it track a wandering bias at the cost of noisier estimates.

Explain it another way: applied

Spacecraft attitude filters routinely carry three gyro bias states. After a few star-tracker fixes, gyro-only coasting during an eclipse or manoeuvre is far more accurate than raw integration.

Try these examples

Example 1

Δt = 0.1 s. Write A for state [p, b] when the prediction subtracts the bias from odometry.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Which measurement makes BOTH position and odometry bias observable in this model?

  • Occasional absolute position fixes
  • Odometry alone
  • No measurements, just a good model
  • Measuring the bias directly only once

2. A filter's position estimate lags behind sudden real slips and the truth often leaves its ±2σ band. The fix is to…

  • Increase Q
  • Decrease Q
  • Decrease R to zero
  • Remove the bias state

3. The filter learns a bias of 1.5 cm/s. During a 40 s camera blackout, how much position drift does subtracting it remove, in cm?

Answer: cm

4. A rover's estimate is x = 5 m with variance P = 2 m². It drives u = 3 m (process noise Q = 2 m²), then a landmark fix reads z = 10 m with R = 1 m². After predict and update, what is the new estimate x, in m?

Answer: m

Apply it

Pre-register a small tuning study in the fusion lab: three Q settings, five seeds each, metric RMSE, decision rule 'lowest mean RMSE, ties broken by consistency'. Run it on seeds 1–5, then report the chosen setting's RMSE on seeds 6–10.

Reflect

What hidden state might a real rover estimate besides odometry bias?

Mission planning: Δv budgets and margins

A spacecraft's tank holds a fixed amount of 'change of speed'. Spend it on the transfer, on corrections for navigation error, on arrival. Run out and the mission ends.

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Δv is the currency of spaceflight, as energy is for a rover. The budget links orbital mechanics to estimation: the better you know where you are, the smaller the correction burns, and the more Δv is left for science.

Goals

Predict

An engine with exhaust speed about 3.1 km/s (Isp ≈ 320 s) must deliver Δv = 2 km/s. Roughly what fraction of the starting mass is propellant?

  1. About 10%
  2. About 47%
  3. About 65%
  4. About 25%

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Plan LEO → geostationary with a 4.0 km/s budget and note the margin. Now 'spend' 5% of the transfer Δv on navigation corrections: does the mission still close? Switch to Earth → Mars and find the smallest budget that closes the idealised transfer.

What the interactive shows, in words

The Hohmann planner's readout states each burn, the total and the margin against the budget slider, so the budgeting exercise can be done entirely from the text readout.

Understand

The budget

List every manoeuvre: departure, mid-course trajectory correction manoeuvres (TCMs), arrival or orbit insertion, attitude control, and end-of-life disposal. Add a margin (often 5–10% early in design) for what is not yet known. The total must not exceed what the propulsion system can deliver.

The rocket equation

Δv = vₑ·ln(m₀/m_f), with exhaust speed vₑ = Isp·g₀ (g₀ = 9.80665 m/s²). Invert it: m₀/m_f = e^(Δv/vₑ). Each extra km/s multiplies the starting mass, which is why margins are argued over and navigation precision is worth so much.

Navigation sets the corrections

After departure the trajectory has a delivery error (an uncertainty ellipse at the target). TCMs remove it, and the Δv they need scales with how large that error is and how late it is corrected. Better orbit determination (more tracking, optical navigation) means smaller, earlier, cheaper corrections.

Explain it another way: intuitive

Like a road trip on one tank: the main drive, a few detours to fix wrong turns, and a reserve. The better your map, the fewer detours.

Explain it another way: technical

Budgets are usually stated at a confidence level, for example 99% TCM Δv from a Monte Carlo of navigation and execution errors, not just the nominal value.

Explain it another way: mathematical

Illustrative budget: departure 3.6 km/s, corrections 0.1 km/s, orbit insertion 1.2 km/s, sum 4.9 km/s; with 10% margin, 5.39 km/s. With vₑ = 3.14 km/s that needs m₀/m_f = e^1.72 ≈ 5.6, so about 82% of the starting mass would be propellant if one stage did it all.

Explain it another way: applied

That huge propellant fraction is why missions use launch vehicles for departure, aerobraking in planetary atmospheres to save insertion Δv, and gravity assists where geometry allows.

Try these examples

Example 1

Isp = 320 s, Δv = 2.0 km/s. Mass ratio and propellant fraction?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. An engine has vₑ = 3,000 m/s. The mass ratio m₀/m_f is 1.5. What Δv does it deliver, in m/s?

Answer: m/s

2. Manoeuvres total 3.2 km/s and the team carries a 10% margin. What total Δv must the propulsion system provide, in km/s?

Answer: km/s

3. Plan a Hohmann transfer from a circular orbit 300 km above Earth to one 5000 km above Earth (radius 6371 km, GM = 3.986e14 m³/s²). What is the total Δv of the two burns, in km/s?

Answer: km/s

4. Why does better navigation reduce the Δv budget?

  • Smaller delivery errors need smaller correction burns
  • Navigation sensors produce thrust
  • Better navigation shortens the Hohmann transfer
  • It does not affect Δv

Apply it

Write a five-line Δv budget for a conceptual Mars orbiter using the planner's Earth → Mars total as the transfer, an allowance for corrections and a 10% margin. Convert the total to a propellant fraction for vₑ = 3.1 km/s, and say which line navigation improvements would shrink.

Reflect

What is the rover-on-the-ground equivalent of a Δv budget, and what plays the role of margin?

Week 18: Autonomous systems investigation

This week you will

Navigation uncertainty ellipses and budgets

'Within 5 km' is not one number. Along the track you may know 4 km; across it, 1.5 km; and the two errors may be linked. Draw that and you get an ellipse.

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Landing sites and rover drive corridors are chosen by fitting uncertainty ellipses inside safe zones. This turns everything you have estimated this term (σ's, correlations, fused covariances) into a yes/no engineering decision.

Goals

Predict

A 2-D position estimate has σ = 1 km in both directions, independent. What fraction of the time is the true position inside the 1σ circle?

  1. About 68%
  2. About 39%
  3. About 95%
  4. About 50%

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Set σ along = 4 km, σ cross = 1.5 km, ρ = 0, 95%. Does the ellipse fit a 20 × 10 km zone? Now set ρ = 0.6 and watch it tilt. Finally, find the largest σ along that still fits at 99%.

What the interactive shows, in words

The diagram draws the uncertainty ellipse inside a rectangular zone; the readout states the semi-axes, tilt, scale factor k, area, extents and whether it fits, entirely in text.

Understand

Covariance to ellipse

Position error [eₓ, e_y] has covariance Σ = [[σₓ², ρσₓσ_y], [ρσₓσ_y, σ_y²]]. Contours of equal probability are ellipses whose axes are Σ's eigenvectors and whose 1σ semi-axes are √(eigenvalues). With ρ = 0 they line up with x and y; correlation tilts them.

Choosing the probability

For a 2-D Gaussian, the probability inside the ellipse scaled by k is p = 1 − e^(−k²/2), so k = √(−2 ln(1 − p)): k = 1 → 39%, 2 → 86%, 2.45 → 95%, 3.03 → 99%. Always state which ellipse you mean: '3σ' and '99%' are different in 2-D.

Budgets and zones

A navigation budget combines contributions (in each axis, by RSS if independent) into Σ. The design check: the p-ellipse must fit inside the safe zone with margin. If it does not, either shrink the uncertainty (more fixes, better sensors) or choose a bigger, safer zone.

Explain it another way: intuitive

Throw many darts at the estimated position with the estimator's errors. They land in an oval blob: long where you know least, short where you know most, tilted if the errors in the two directions tend to go together.

Explain it another way: technical

The squared Mahalanobis distance d² = eᵀΣ⁻¹e of a 2-D Gaussian error follows a χ² distribution with 2 degrees of freedom, whose CDF is 1 − e^(−d²/2): the source of the k formula.

Explain it another way: mathematical

σₓ = 4, σ_y = 1.5 km, ρ = 0, p = 0.95: k ≈ 2.448, semi-axes ≈ 9.79 × 3.67 km, area πk²σₓσ_y ≈ 113 km². σₓ = σ_y = 2, ρ = 0.5: eigenvalues 4(1 ± 0.5), semi-axes √6 ≈ 2.45 and √2 ≈ 1.41, tilted 45°.

Explain it another way: applied

Entry, descent and landing teams publish landing ellipses (typically quoted at 99%) and planetary geologists choose targets that keep hazards out of them. Improved guidance during entry is what lets modern ellipses be small enough to aim near cliffs and craters.

Try these examples

Example 1

σₓ = 4 km, σ_y = 1.5 km, independent. Will the 95% ellipse fit a zone 20 km long by 10 km wide?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. What scale factor k gives a 2-D ellipse containing 99% probability (3 decimal places)?

Answer:

2. σₓ = σ_y = 3 km with correlation ρ = 0.5. What is the 1σ semi-major axis, in km?

Answer: km

3. A landing-position error budget has four independent 1σ contributions: entry navigation 2 km, atmosphere 4 km, aerodynamics 5 km and timing 1.5 km. What is the combined 1σ error (root-sum-square), in km?

Answer: km

4. A report says 'the rover is within the 1σ ellipse'. How confident should you be that the true position is inside it?

  • About 39%
  • About 68%
  • About 95%
  • Certain

Apply it

Build a navigation budget for a 200 m rover drive: odometry slip, heading drift and one landmark fix at the end (use inverse-variance fusion for the fix). Express the result as σ along and across track, and test the 95% ellipse against a 4 m wide corridor in the diagram.

Reflect

Why might an engineer choose a 99% ellipse for landing but a 95% ellipse for a science target?

Light-time delay and why rovers must decide alone

A Mars rover sees a hazard. A human could help, but the question takes up to 22 minutes to arrive and the answer another 22. What should the rover do in the meantime?

About 40 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

Delay is the reason estimation matters so much in space: nobody can watch and steer. Every autonomy design decision, from how far to drive between photos to when to stop and wait, is a trade between delay, uncertainty and risk.

Goals

Safety: All rover activities are browser simulations; no hardware is involved.

Predict

Mars is 225 million km away. How long from sending a command until Earth sees the rover's reply (ignoring processing)?

  1. About 12.5 minutes
  2. About 25 minutes
  3. About 2 minutes
  4. About 1 hour

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Open BUILD 006 Level 4: dust-storm season, Earth 20 minutes away. Plan the route, checkpoints, camera trust and dust rule so the rover arrives within 1 m on all five sols. Calculate the cost of one 'ask Earth' stop before deciding whether to use it.

What the interactive shows, in words

BUILD 006 Level 4 can be planned from its text descriptions of the routes, checkpoints and rules; the delay and energy calculations are stated in this lesson's worked examples.

Understand

Delay is distance over c

t = d/c, c ≈ 3.00 × 10⁸ m/s. Moon: 1.28 s. Mars: about 3 min at closest (≈ 55 million km) to about 22 min at farthest (≈ 401 million km). Jupiter: around 35 min or more. Round trip doubles it, and real operations add hours: antenna scheduling, planning, checking.

From joystick to plans

With seconds of delay you can teleoperate. With minutes, you send plans: a sequence of drives and checks for a whole sol, uploaded in one communication window. The rover executes alone and reports back. Its onboard estimator decides when the plan's assumptions are broken.

Safety rules from estimates

Autonomy needs rules phrased in terms of uncertainty: 'stop if the 95% ellipse leaves the corridor', 're-image if the landmark is lost for more than N steps', 'halt and wait for Earth if the battery reserve would be breached'. Each rule trades delay (waiting costs a sol) against risk.

Explain it another way: intuitive

Imagine steering a car by phone where each instruction arrives 20 minutes late. You would not steer; you would give the driver a route and some rules, and trust them.

Explain it another way: technical

Operations tempo is set by the round-trip delay plus planning time: Mars rovers have traditionally been commanded about once per sol. Onboard autonomy (autonomous navigation, hazard avoidance) extends what one plan can safely do.

Explain it another way: mathematical

Asking Earth costs 2 × t_one-way + t_planning. With 20 min one way and 20 min of planning: 60 min. If the drive window is 3 h, one question uses a third of it.

Explain it another way: applied

That is why BUILD 006 makes 'wait for Earth' a costly option: in Level 4 it uses up the sol's time window, so the plan must handle dust by itself.

Try these examples

Example 1

Mars at 401 million km: one-way delay?

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Jupiter is 630 million km from Earth. Using c = 3.0 × 10⁸ m/s, what is the round-trip (command and reply) light-time delay, in minutes?

Answer: min

2. Earth is 15 light-minutes from the rover and the team needs 30 minutes to decide. How long does one 'ask Earth' stop cost, in minutes?

Answer: min

3. Which onboard rule makes best use of a Kalman filter's output during a long delay?

  • Stop and re-image when the position σ exceeds a threshold
  • Always drive to the end of the plan
  • Stop every 10 m regardless
  • Ask Earth before every turn

4. The Moon is about 384,400 km away. What is the round-trip delay, in seconds (c = 3.0 × 10⁸ m/s)?

Answer: s

Apply it

Write the three most important onboard rules for your BUILD 006 Level 4 plan, each in the form 'if [estimate condition] then [action]'. For each, state the cost in time if it triggers and the risk if it does not exist.

Reflect

What should a rover do if its estimator and its hazard camera disagree and Earth is 20 minutes away?

Investigation: where is the rover?

Dead reckoning, a complementary filter or a Kalman filter: which keeps a dust-blinded rover closest to the truth, and how sure can you be of the answer?

About 60 min · Checked by automated tests · Interactive lesson · Lite lesson (answers checked here)

Why it matters

This is the term project in miniature and a dress rehearsal for the research year. The question is real engineering: which estimator should a rover trust when its camera is unreliable? The skill is research integrity: deciding how you will judge before you look.

Goals

Safety: All rover activities are browser simulations; no hardware is involved.

Predict

As dust blocks the landmark more often, the Kalman filter's advantage over dead reckoning will…

  1. Shrink, because it gets fewer fixes to correct with
  2. Grow without limit
  3. Stay exactly the same
  4. Reverse: dead reckoning wins in dust

Write down your guess and your reason. The reveal is in the online lesson.

Discover

Open BUILD 006 Level 5. Before running anything, write your hypothesis, metric (for example final position error), at least three dust levels and your decision rule. Then hold the route and everything else fixed, change only the variable you chose, and record at least four runs per condition. Cross-check one condition in the fusion lab.

What the interactive shows, in words

BUILD 006 Level 5 records each run's numbers on our server; the investigation can be planned and reported entirely in text, with results as a table of mean ± SE per condition.

Understand

Pre-register

Write down, before collecting data: the question, the hypothesis (a direction and a size, e.g. 'Kalman reduces final error by at least 30% at 50% dust'), the metric, the conditions, the number of seeds, and the decision rule. Changes after seeing data are allowed but must be reported as deviations.

A fair comparison

Include the baseline (dead reckoning) so improvements have a reference. Give every estimator the same sensors, seeds and tuning effort; tune on different seeds from the ones you report. Change one variable at a time. Repeated seeds turn one lucky run into a mean ± standard error.

Report honestly

Show results per condition with error bars (SE = s/√n across seeds). Say what the simplified model leaves out: 1-D or grid motion, Gaussian noise, known noise levels, no wheel faults. Do not claim the result transfers to a real rover; claim what the simulation supports.

Explain it another way: intuitive

A fair race: same track, same weather, same number of laps for every runner, and you decide how to judge the winner before the race starts.

Explain it another way: technical

With few seeds per condition, report a t-based interval rather than ±1.96 SE, and prefer paired comparisons (same seed, different estimator) to reduce variance from the scenario itself.

Explain it another way: mathematical

If the Kalman final errors at one dust level over 5 seeds are 0.42, 0.55, 0.38, 0.61, 0.47 m: mean 0.486 m, s ≈ 0.094 m, SE ≈ 0.042 m. A paired difference against dead reckoning on the same seeds gives a tighter comparison.

Explain it another way: applied

Space agencies validate navigation software in exactly this way before flight, with large simulation campaigns across seeded conditions and pre-agreed pass/fail criteria.

Try these examples

Example 1

Five seeds give final errors 0.42, 0.55, 0.38, 0.61, 0.47 m. Report mean ± SE.

The worked solution is in the online lesson.

Common mix-ups

Practice questions

Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.

1. Which belongs in a pre-registration?

  • The decision rule you will use to judge the hypothesis
  • The results
  • The conclusion
  • The best-looking graph

2. Final errors over 4 seeds have standard deviation s = 0.2 m. What is the standard error of their mean, in m?

Answer: m

3. n = 64 readings of a wheel's radius have standard deviation s = 1.2 mm. Using z = 1.96 (large n), what is the half-width of the 95% confidence interval for the mean radius, in mm?

Answer: mm

4. You tuned the Kalman filter's Q on seeds 1–5 and report results on seeds 1–5. What is the problem?

  • The reported error is optimistically biased: tuning and testing used the same data
  • Nothing
  • Too many seeds
  • The baseline is unfair to Kalman

5. Your simulation shows the Kalman filter halves final error at 50% dust. Which conclusion is justified?

  • In this simplified simulation, under these conditions, the Kalman filter halved final error (mean ± SE over n seeds)
  • Kalman filters halve rover errors on Mars
  • Kalman filters are always better
  • Dead reckoning should never be used

Apply it

Complete the term project 'Where is the rover?': pre-registration, at least three dust levels with repeated seeds, the dead-reckoning baseline plus two fusion estimators, a navigation uncertainty budget and the light-time delay for your scenario, and a short report with an honest limitations section.

Reflect

What result would surprise you most, and what would you do if you got it?