Bayes' theorem and the base-rate trap
Why a positive result on a 99%-accurate test can still mean you're probably fine — updating belief with evidence.
Slide the three dials — watch the posterior
Posterior P(has it | tested +)
16.7%
Of the 594 who test positive per 10,000, only 99 truly have it.
If the test is negative
100% clear
P(healthy | tested −) — usually reassuringly high.
Here's a puzzle that fools doctors. A disease affects 1 in 100 people. A test for it is 99% accurate. You test positive. How worried should you be? Most people say "99%." The real answer is closer to 17%. Understanding why is understanding Bayes' theorem — the rule for updating what you believe when new evidence arrives, and the engine behind spam filters and medical screening. Let's derive it and then compute the puzzle.
Updating a belief
Bayes' theorem connects two "backwards" questions. You often know P(evidence | cause) — e.g., "if you have the disease, the test is positive 99% of the time." But you want P(cause | evidence) — "given a positive test, do I have the disease?" Bayes flips one into the other:
The pieces have names you'll meet everywhere in AI:
- — the prior: your belief before the evidence (here, 1% — the disease is rare).
- — the likelihood: how well the cause explains the evidence (a sick person testing positive).
- — the posterior: your updated belief after the evidence.
- — the evidence: how common the evidence is overall.
That bottom term is found by adding up every way the evidence can happen:
(Here means "not A" — being healthy.) In one line: posterior ∝ likelihood × prior.
Solving the puzzle
Let's plug in the numbers. Disease is rare, test is accurate:
- Prior: (1%)
- Sensitivity: (a sick person tests positive 99% of the time)
- False-positive rate: (5% of healthy people wrongly test positive)
Step 1 — the top (likelihood × prior):
P(+ | disease) × P(disease) = 0.99 × 0.01 = 0.0099
Step 2 — the bottom (all the ways to test positive):
sick & positive = 0.99 × 0.01 = 0.0099
healthy & positive = 0.05 × 0.99 = 0.0495
P(+) total = 0.0099 + 0.0495 = 0.0594
Step 3 — divide:
P(disease | +) = 0.0099 / 0.0594 ≈ 0.167 → about 17%
Even after a positive result on a 99%-accurate test, you're only ~17% likely to actually have the disease. Surprising? Here's the picture, per 10,000 people:
100 people have it → 99 test positive (true positives)
9,900 are healthy → 495 test positive (false positives, 5% of 9,900)
positives in total = 99 + 495 = 594
truly sick among them = 99 / 594 ≈ 17%
The disease is so rare that the flood of false positives from the huge healthy majority outnumbers the true positives. This is the base-rate trap: the prior matters as much as the test's accuracy. Ignoring it is one of the most common reasoning mistakes there is.
Why this matters for AI
- Naive Bayes classifiers pick the category with the highest posterior — spam vs. not-spam is literally
P(spam | these words)computed with Bayes. - Any rare-event model (fraud, disease, defects) lives and dies by the base rate — which is why "99% accuracy" can be a terrible model when the thing you're detecting is rare.
- It's the mathematical heart of updating beliefs with data, which is what learning is.
Now feel it. Drag the three sliders below — prevalence, sensitivity, false-positive rate — and watch the posterior swing. Push the disease rarer and see the "99% accurate" test's answer collapse, exactly as we computed.
This is one idea from a curriculum that builds probability from the ground up. Try a free lesson and compute a posterior yourself.