Lite / Independent Engineering Research / Week 13
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.
Why should I care?
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.
- Apply Bayes' rule to update a belief after a sensor reading.
- Explain prior, likelihood, evidence and posterior in a sensing example.
- Chain updates from several independent readings.
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?
- 90%
- About 67%
- 95%
- 10%
Guess first, then reveal
P = 0.9 × 0.1 / (0.9 × 0.1 + 0.05 × 0.9) = 0.09/0.135 ≈ 0.67. One in three alarms is false, because safe rocks are so much more common.
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 (text version)
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.
Watch (optional)
Watch for: Watch how the prior and the evidence are drawn as areas: the posterior is the share of the 'evidence happened' area that belongs to each hypothesis.
Pictures prior, evidence and posterior as areas, so updating a belief on new evidence feels like common sense rather than a formula.
“A visual guide to Bayesian thinking” by Julia Galef (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
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.
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.
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.
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.
Worked example 1
Prior 0.02, hit rate 0.95, false-alarm rate 0.02. Posterior after one alarm?
0.95 × 0.02 = 0.019; 0.02 × 0.98 = 0.0196. P = 0.019/0.0386 ≈ 0.49.
Common mix-ups
P(E | H) and P(H | E) are the same thing.
✓ They can be wildly different: a 90% hit rate does not make 90% of alarms real.More readings always mean more certainty.
✓ Only if they are independent. Correlated readings repeat the same mistake.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
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?
Write your answer on paper or in your own notes. Lite never stores what you write.