TactivergeLite

Lite / Textbooks / The Mathematics of Machines / Chapter 9

9. Probability and uncertainty

Version 1 · Technically checked (automated checks only) · 4 source lessons · Full interactive version

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.

Figure 9.1. A fault test in natural frequencies (described in words)

A tree starting with 10,000 parts. 100 are faulty and 9,900 are good. The test flags 90 of the 100 faulty parts and 495 of the 9,900 good ones. Of the 585 flagged parts, only 90 are faulty: about 15 %.

Explanation

Built from 4 School lessons. Each part is the lesson's own explanation.

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
  1. Events: F = 'part is faulty', + = 'detector flags it'. P(A | B) means 'the probability of A among the cases where B happened'.

  2. Imagine N parts. Faulty: N·P(F). Of those, flagged: N·P(F)·P(+ | F).

  3. Good: N·(1 − P(F)). Of those, flagged: N·(1 − P(F))·P(+ | not F).

  4. 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)].

  5. N cancels. The denominator is P(+), the overall chance of a flag. So P(F | +) = P(+ | F)·P(F) ÷ P(+): Bayes' rule.

  6. 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.

  7. P(F | +) and P(+ | F) are different questions: 15% versus 90%. Confusing them is called the base-rate fallacy.

Common mix-ups

Open the Lite 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

Open the Lite 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

Open the Lite lesson: Binomial, Poisson and normal

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

Open the Lite 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, in words

Figure 9.2 from Conditional probability, Bayes and base rates

Start at base rate 1%, sensitivity 90%, false positives 5%. Read the counts in each branch and check the answer by hand. Then raise the base rate to 20%. Then go back to 1% and halve the false-positive rate. Which change helps the flags most? Finally, try 'tested a second time'.

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%.

Figure 9.3 from Binomial, Poisson and normal

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σ.

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.

Figure 9.4 from The central limit theorem by simulation

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.

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.

The interactive versions are in the full chapter.

Laboratory

These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.

Practice

Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.

  1. Out of 1000 parts, 20 are faulty and flagged and 60 are good but flagged. What is P(faulty | flagged), as a percentage?
    Answer it in “Conditional probability, Bayes and base rates”
  2. P(flagged | faulty) = 0.95. Which statement follows?
    Answer it in “Conditional probability, Bayes and base rates”
  3. What is the variance of 3X + 5, where X is one roll of a fair die (Var(X) = 35/12)?
    Answer it in “Random variables, expectation and variance”
  4. Which statement is true for ANY two random variables X and Y?
    Answer it in “Random variables, expectation and variance”
  5. Which count is best modelled as Poisson?
    Answer it in “Binomial, Poisson and normal”
  6. A camera succeeds with p = 0.25 on each of n = 40 independent attempts. What is the variance of the number of successes?
    Answer it in “Binomial, Poisson and normal”
  7. Readings have σ = 4 mm. How many must be averaged to get a standard error of 0.5 mm?
    Answer it in “The central limit theorem by simulation”
  8. Which condition is essential for the CLT as stated in this lesson?
    Answer it in “The central limit theorem by simulation”

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)

Streaming video uses a lot of data. Everything you need is in the text.

Summary

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. Field Guide
Standard deviation
Standard deviation measures how spread out values are around their mean: the square root of the average squared distance from the mean. Field Guide
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. Field Guide
Random and systematic error
Random errors scatter readings unpredictably above and below the true value; systematic errors shift every reading the same way. 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

Write it up on paper or in your own notes. Lite never stores what you write.

References

← 8. Differential equations10. Linear systems →