RobotGuide

Math foundations · topic A2 · 30 hours

Probability, statistics & Bayes

State estimation, SLAM, sensor fusion — all of it stands on the Bayesian framework. Without understanding posterior and likelihood, you can only recite Kalman filter formulas, not use them.

Foundations stage · Intermediate
Algorithm · Proficient System software · Aware

Tools
Tools

What to learn

  • Gaussian distributions, covariance, and covariance propagation: Σ' = FΣFᵀ + Q after linearization
  • The predict–update two steps of the Bayesian filter: what the prior, likelihood, and posterior each correspond to in engineering
  • The hand derivation of one-dimensional Gaussian fusion: how two sensors get weighted, and who decides the weights
  • Mahalanobis distance and the chi-square test: how to decide whether a measurement is an outlier
  • Why «the ratio of Q to R» decides who the system trusts, not their absolute values

The lesson · plain words

Every sensor lies: encoders have quantization error, IMUs drift, cameras are noisy. A robot spends every moment «guessing the truth from imperfect measurements» — probability theory is the discipline that keeps the books for that guessing. It is not fortune-telling; it turns uncertainty into numbers and then makes optimal decisions.

Good news: the probability knowledge a robot engineer actually uses comes in three pieces — distributions (what error looks like), Bayes (how new evidence corrects old beliefs), and expectation (what the long-run average does). This page covers all three with three examples.

The normal distribution: a bell curve that portraits error

A ranging radar spec of ±3 cm means «the true error lands within ±3 cm with about 68% probability». That 3 cm is σ (the standard deviation) — a fat curve means a large σ and a lousy sensor; a thin curve means a small σ and trustworthy readings. Every filter and every sensor fusion you will ever see takes this curve as its input.

The animation below shows the advanced use: fuse two imperfect rulers (two distributions) and the resulting bell is always narrower than either single ruler — «inverse-variance weighting» in animated form. This is the intuition kernel of the Kalman filter.

Interactive figure · drag it and see

What this figure shows: two Gaussian curves labeled Ruler A and Ruler B, each with a live σ readout in mm; you drag either curve to change its spread, and the fused σ is displayed alongside — always narrower than either ruler alone. Takeaway: fusing two noisy sensors always beats trusting either one — the fused uncertainty is smaller than the best individual sensor's.

Bayes: testing positive ≠ being sick

The classic numbers problem: disease prevalence 1%, test accuracy 95%. You test positive — what is the probability you are actually sick? Here is the count: out of 1000 people, about 9.5 of the 10 true patients test positive; among the 990 healthy people, about 49.5 get falsely flagged. So the truly sick share among the positives = 9.5 ÷ (9.5 + 49.5) ≈ 16%.

Intuition shouts 95%, Bayes says 16% — because «the prior is too rare» (1% prevalence) outweighs «the evidence is quite strong» (95% accuracy). The robot version is the same story: 99% of the signs at an intersection say «speed limit 60»; one day the recognition module outputs 95% confidence for a «stop» sign — the prior says do not rush to believe it.

The formula is one line: posterior ∝ prior × likelihood. The problem above is just this formula counting people.

Interactive figure · drag it and see

What this figure shows: a population of 500 people — orange = sick, purple = false alarms, blue = missed cases, gray = healthy — with sliders for prevalence and test accuracy; it displays how many tested positive and what share of the positives is truly sick, next to what your gut would say. Takeaway: when the prior is rare, even strong evidence gets discounted heavily — always multiply by the prior before trusting a classifier's confidence.

Expectation: the objective function of reinforcement learning is exactly this

«How much reward you get on average» = the expectation, written E[·]. Translated into plain words, the RL objective max E[reward] says: ignore single-run luck, watch the long-run average. Variance answers the other half of the question: does this policy perform steadily, or swing between brilliant and disastrous.

Engineering intuition: large variance = a policy with a high average score that occasionally causes a catastrophe — on real hardware you would usually rather take the one with a slightly lower average and small variance.

Interactive figure · drag it and see

What this figure shows: a die being rolled over and over (with a reroll button); the sample mean converges to E[X] = 3.5 while the jitter shrinks ∝ 1/√n, so the band narrows as the roll count grows. Takeaway: a single outcome tells you almost nothing — only the long-run average, the expectation, is what a policy actually optimizes.

Three sentences to take away

① σ is the «radius» of error, and it only shrinks after fusion; ② Bayes = using the prior to discount the evidence; ③ E[·] = the long-run average, the entire objective of RL. The Kalman filter is the recursive version of these three sentences, expanded in B7.

Three questions — do you really get it?

1. A sensor's σ doubles. How many times wider does the 68% interval become?

  • AUnchanged
  • B4×
  • C2×
Show answer

C. The 68% interval is ±1σ, so doubling σ widens it by the same factor. Variance is the quantity that quadruples.

2. Prevalence 1%, test accuracy 95% — after testing positive, the probability you are truly sick is about?

  • A16%
  • B50%
  • C95%
Show answer

A. The false-positive crowd (49.5 per thousand) far outnumbers the true positives (9.5 per thousand). When the prior is rare, the evidence gets discounted heavily.

3. In the RL objective max E[reward], what does E stand for?

  • AThe symbol for energy
  • BError
  • CThe long-run average (expectation)
Show answer

C. Ignore single-run luck; watch the policy's long-run average reward — that is precisely the definition of «expectation».

Keep going deeper

Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.

How it fails in the field

  • Filling in Q and R carelessly; when fusion looks bad you swap the algorithm, swap through a whole list, and it is still bad
  • Treating covariance as a diagonal matrix and ignoring correlation between sensors — the filter grows ever more confident

You have learned enough when

You can explain the predict–update two steps of a Bayesian filter, hand-derive one-dimensional Gaussian fusion, and say clearly why the ratio of process noise to measurement noise decides «who to trust».

The Chinese edition carries the full topic page for Probability, statistics & Bayes, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/A2/.