Textbooks/The Mathematics of Machines/Chapter 9
9Probability and uncertainty
Version 1 · Technically checked (automated checks only) · 4 source lessons · 8 practice items
Introduction
Sensors are noisy, parts are sometimes faulty and tests sometimes lie. Probability lets engineers reason about all of that with numbers. This chapter counts its way through Bayes' rule, defines expectation and variance, meets the three distributions that turn up most often (binomial, Poisson and normal) and shows, by simulation, why averages of many readings become normal.
Explanation
This chapter is built from 4 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.
9.1 Conditional probability, Bayes and base rates
A detector catches 90% of faults and false-alarms only 5% of the time. A part is flagged. Is it probably faulty?
Events and conditions
An event is something that does or doesn't happen: 'faulty', 'flagged'. P(F) is its probability over all parts. A conditional probability P(F | +) restricts attention to the cases where + happened. Reading '|' as 'among those that' keeps it straight: the share faulty among those that were flagged.
Count, don't juggle formulas
The safest way to apply Bayes' rule is a frequency tree: pick a population (10,000 is convenient), split it by the base rate, then split each branch by the detector's rates, and finally compare the branches that match the evidence. The formula and the counts give the same answer; the counts are harder to get wrong.
Base rates rule
When the condition is rare, false alarms from the huge 'good' group can outnumber real detections from the tiny 'faulty' group. Two remedies: reduce the false-positive rate, or confirm a flag with a second, independent check, using the first answer as the new base rate. Independence is an assumption: two sensors fooled by the same glare are not independent.
Derivation: Bayes' rule from a frequency table
Events: F = 'part is faulty', + = 'detector flags it'. P(A | B) means 'the probability of A among the cases where B happened'.
Imagine N parts. Faulty: N·P(F). Of those, flagged: N·P(F)·P(+ | F).
Good: N·(1 − P(F)). Of those, flagged: N·(1 − P(F))·P(+ | not F).
Among all flagged parts, the share that are faulty is P(F | +) = N·P(F)·P(+ | F) ÷ [N·P(F)·P(+ | F) + N·(1 − P(F))·P(+ | not F)].
N cancels. The denominator is P(+), the overall chance of a flag. So P(F | +) = P(+ | F)·P(F) ÷ P(+): Bayes' rule.
Numbers: P(F) = 0.01, P(+ | F) = 0.9, P(+ | not F) = 0.05: P(F | +) = 0.009 ÷ (0.009 + 0.0495) = 0.009 ÷ 0.0585 ≈ 0.154.
P(F | +) and P(+ | F) are different questions: 15% versus 90%. Confusing them is called the base-rate fallacy.
Common mix-ups
- If a test is 95% accurate, a positive result is 95% likely to be right.
✓ That depends on the base rate. For rare conditions a positive can still be more likely wrong than right. - Two checks always multiply the evidence.
✓ Only if their errors are independent. Checks fooled by the same cause add little.
Open the full lesson: Conditional probability, Bayes and base rates →
9.2 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'.
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.
Common mix-ups
- The expected value is the most likely value.
✓ It is the long-run average. A die's expectation, 3.5, is impossible on any single roll. - Independent errors add up linearly.
✓ Their variances add, so σ grows like √n. Only biases add linearly.
Open the full lesson: Random variables, expectation and variance →
9.3 Binomial, Poisson and normal
Counting sightings, counting cosmic-ray hits, measuring a range: three different questions, three distributions engineers reach for again and again.
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).
Common mix-ups
- Any count is binomial.
✓ Binomial needs a fixed n, independent trials and a constant p. Events at a rate with no natural n are Poisson; bursty events are neither. - Normal probabilities need integration every time.
✓ Standardise to z and use Φ: a z-table (or Φ function) is that integral done once for everyone.
9.4 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?
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.
Common mix-ups
- The CLT says the data become normal if you collect enough.
✓ The data keep their shape. It is the distribution of the sample MEAN that becomes normal. - Averaging fixes all errors.
✓ It shrinks independent random error like 1/√n and does nothing to a shared bias.
Open the full lesson: The central limit theorem by simulation →
Worked examples
Conditional probability, Bayes and base rates: example 1
Base rate 10%, sensitivity 80%, false positives 10%. P(faulty | flagged)?
Solution
Out of 1000: 100 faulty → 80 flagged; 900 good → 90 flagged. P = 80 ÷ 170 ≈ 47%.
Random variables, expectation and variance: 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).
Solution
E[X] = 0 + 0.2 + 0.6 + 1.2 = 2.0. E[X²] = 0 + 0.2 + 1.2 + 3.6 = 5.0. Var(X) = 5.0 − 2.0² = 1.0, so σ = 1.
Random variables, expectation and variance: example 2
Each of 25 independent wheel steps has error with σ = 2 cm and mean 0. What is the σ of the total error?
Solution
Variances add: 25 × 4 = 100 cm², so σ_total = 10 cm. (Not 25 × 2 = 50 cm: independent errors partly cancel.)
Binomial, Poisson and normal: example 1
Landmark sightings succeed with p = 0.8 independently. Probability of exactly 8 in 10?
Solution
C(10, 8) = 45. 45 × 0.8⁸ × 0.2² = 45 × 0.16777 × 0.04 ≈ 0.302.
Binomial, Poisson and normal: example 2
Range readings are normal with μ = 50 m, σ = 2 m. What is P(reading < 47 m)?
Solution
z = (47 − 50)/2 = −1.5. Φ(−1.5) = 1 − Φ(1.5) ≈ 1 − 0.9332 = 0.0668.
The central limit theorem by simulation: example 1
A gyro sample has σ = 0.8 °/s. How many samples must be averaged for SE = 0.1 °/s?
Solution
σ/√n = 0.1 ⇒ √n = 8 ⇒ n = 64.
Interactive figures
Interactive figure (online). Description: The base-rate tree splits 10,000 parts by base rate into faulty and good, then each into flagged and not flagged. At base rate 1%, sensitivity 90% and false positives 5%: 100 faulty (90 flagged, 10 missed) and 9,900 good (495 flagged, 9,405 passed). P(faulty | flagged) = 90 ÷ 585 ≈ 15.4%. A second independent flag raises it to about 77%.
Interactive figure (online). Description: 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.
Interactive figure (online). Description: 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.
Laboratory
Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.
Equation Lab exploration
Equation Lab: Distributions
Change the sample size and watch the spread of the sample mean shrink like 1/sqrt(n).
Open Equation Lab: Distributions →Simulation OS experiment
Simulation OS: Two-sensor fusion
Combine two noisy sensors and check that the fused variance is smaller than either one.
Open Simulation OS: Two-sensor fusion →Playground lab
Playground: Sensor fusion
Compare each sensor's error with the fused estimate while the camera drops out.
Open Playground: Sensor fusion →
Guided practice
Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.
- Out of 1000 parts, 20 are faulty and flagged and 60 are good but flagged. What is P(faulty | flagged), as a percentage? (%)
- P(flagged | faulty) = 0.95. Which statement follows?
- P(faulty | flagged) = 0.95
- Nothing about P(faulty | flagged) without the base rate and false-positive rate
- P(faulty | flagged) = 0.05
- What is the variance of 3X + 5, where X is one roll of a fair die (Var(X) = 35/12)?
- 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)
- 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
- A camera succeeds with p = 0.25 on each of n = 40 independent attempts. What is the variance of the number of successes?
- Readings have σ = 4 mm. How many must be averaged to get a standard error of 0.5 mm?
- 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
Engineering applications
Quality control
When faults are rare, even a good test flags more good parts than faulty ones, as the figure shows. Factories confirm flagged parts with a second, independent check before rejecting them.
Averaging sensor readings
Averaging n independent readings divides the standard deviation of the noise by sqrt(n). Four readings halve it; a hundred cut it to a tenth, at the cost of time.
Watch
Optional verified videos. Nothing loads from YouTube until you press play.
- The medical test paradox, and redesigning Bayes' rule (3Blue1Brown)
- Binomial distributions | Probabilities of probabilities, part 1 (3Blue1Brown)
- The Normal Distribution, Clearly Explained!!! (StatQuest with Josh Starmer)
- Central limit theorem | Inferential statistics | Probability and Statistics | Khan Academy (Khan Academy)
Chapter summary
- P(A | B) is the probability of A among the cases where B happened; it is not the same as P(B | A).
- Counting natural frequencies (out of 10,000, say) is the safest way to apply Bayes' rule.
- E[aX + b] = a·E[X] + b and Var(aX + b) = a^2·Var(X); variances of independent variables add.
- Binomial: n tries with fixed p. Poisson: counts of rare events in a fixed time. Normal: sums of many small effects.
- The sample mean of n independent readings has standard error σ/sqrt(n), and its distribution becomes close to normal as n grows.
Glossary
- Mean and median
- The mean is the sum of the values divided by how many there are; the median is the middle value once the values are sorted.
- Standard deviation
- Standard deviation measures how spread out values are around their mean: the square root of the average squared distance from the mean.
- Standard error of the mean
- The standard error of the mean estimates how much a sample mean would vary between repeated experiments: the sample standard deviation divided by the square root of the number of readings.
- Random and systematic error
- Random errors scatter readings unpredictably above and below the true value; systematic errors shift every reading the same way.
Definitions from the Field Guide.
Project: Is the alarm worth trusting?
A smoke alarm detects 95 % of real fires and false-alarms on 1 % of ordinary days; real fires happen on 1 day in 10,000. Use natural frequencies to find how often an alarm means a real fire, then propose a second check that would raise that figure and show the new calculation.
Deliverables
- A frequency tree with every count
- P(fire | alarm) before and after your second check
- A sentence on the cost of a missed fire versus a false alarm
Keep your work in your Engineering Journal; it stays private unless you choose to share it.
References
- Joseph K. Blitzstein and Jessica Hwang (2019). Introduction to Probability, 2nd edition. CRC Press.
- Barbara Illowsky and Susan Dean (2013). Introductory Statistics. OpenStax. Link ↗
Publication record
- Version
- 1
- Status
- Technically checked (automated checks only)
- Technical review
- Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
- Written by
- Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
- Licence
- All rights reserved by the founders unless a licence is approved.
- Corrections
- None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.