Bayes' Theorem and the Base-Rate Fallacy
Reverse conditional probabilities with Bayes' theorem, see why a positive result for a rare condition is often a false alarm, and solve the Monty Hall puzzle.
Welcome back!
Step 1 of 12Learn
A positive test for a rare disease
A disease affects 1% of people. A screening test catches 90% of people who have it (its sensitivity) and correctly clears 95% of people who don't (its specificity), so it gives a false positive 5% of the time. You test positive. What is the chance you actually have the disease?
Most people, including many doctors in published surveys, guess something near 90%. The real answer is about 15%.
The easiest way to see it is with natural frequencies. Imagine 10,000 people:
- 100 have the disease. 90% of them, 90 people, test positive.
- 9,900 don't. 5% of them, 495 people, test positive anyway.
In total 90 + 495 = 585 people test positive, and only 90 of them are sick: 90/585 ≈ 15.4%.
The test is good. The problem is that healthy people vastly outnumber sick people, so even a small false-positive rate applied to a huge group produces more false alarms than true cases. Ignoring how rare the condition is, the base rate, is called the base-rate fallacy.
The question "what is P(disease | positive)?" is the reverse of what the test's makers report, P(positive | disease). Bayes' theorem is the tool that flips one into the other.
Step 2 of 12Practice · Diagram
10,000 people take the test
Natural frequencies make Bayes visible. Tap each branch to see how the positives pile up.
Which branch contributes the most positive results?
Tap the shape that answers the question, then press Check.
- 10,000 people
- 100 have it (1%)
- 9,900 do not (99%)
- 90 test positive
Sensitivity 90%: true positives.
- 10 test negative
Missed cases (false negatives).
- 495 test positive
5% of 9,900 healthy people: false positives.
- 9,405 test negative
Correctly cleared.
Step 3 of 12Learn
Bayes' theorem
Start from the multiplication rule written both ways: P(A ∩ B) = P(B | A)·P(A) = P(A | B)·P(B). Divide by P(B):
P(A | B) = P(B | A) · P(A) / P(B)
The denominator usually comes from the law of total probability. If A either happens or doesn't, then
P(B) = P(B | A)·P(A) + P(B | A′)·P(A′)
Each piece has a name:
- P(A) is the prior: what you believed before the evidence (the 1% base rate).
- P(B | A) is the likelihood: how probable the evidence is if A is true (90% sensitivity).
- P(A | B) is the posterior: your updated belief after seeing the evidence.
For the test: P(D | +) = (0.90 × 0.01) / (0.90 × 0.01 + 0.05 × 0.99) = 0.009 / 0.0585 ≈ 0.154.
Updating again. Suppose you take a second, independent test and it is also positive. Your new prior is 0.154:
P(D | ++) = (0.90 × 0.154) / (0.90 × 0.154 + 0.05 × 0.846) ≈ 0.139 / 0.181 ≈ 0.77.
One positive result moved you from 1% to 15%; a second moved you to 77%. This is why positive screening results are confirmed with follow-up testing before anyone acts on them.
Step 4 of 12Try the calculator
Bayes test calculator
Enter how common the condition is and the test's accuracy to see what a result really means.
- P(condition | positive)
- 15.4 %
- P(no condition | negative)
- 99.89 %
- Positives per 10,000 people tested
- 585
Step 5 of 12Practice · Work it out
A condition has a prevalence of 2%. A test has 95% sensitivity and a 10% false-positive rate. What is the probability, in percent, that someone who tests positive has the condition? Round to one decimal.
Step 6 of 12Note
Step 7 of 12Learn
The Monty Hall problem
A game show has three doors. Behind one is a car; behind the others, goats. You pick door 1. The host, who knows where the car is, opens another door, say door 3, to reveal a goat. He offers you the chance to switch to door 2. Should you?
Most people say it doesn't matter: two doors left, 50/50. In fact, switching wins 2/3 of the time.
Reason it out. Your first pick is right with probability 1/3. That doesn't change when the host opens a door, because he can always show a goat no matter what you picked. So staying wins 1/3 of the time, and switching must win the remaining 2/3.
Bayes confirms it. Let C₂ be "car behind door 2" and H₃ be "host opens door 3." If the car is behind door 1, the host chooses door 2 or 3 at random: P(H₃ | C₁) = 1/2. If it's behind door 2, he must open door 3: P(H₃ | C₂) = 1. If it's behind door 3, he can't open it: P(H₃ | C₃) = 0. With priors of 1/3 each:
P(C₂ | H₃) = (1 × 1/3) / (1/2 × 1/3 + 1 × 1/3 + 0) = (1/3)/(1/2) = 2/3.
The key is the host's knowledge. His choice is evidence. If he opened a door at random and happened to reveal a goat, the odds really would be 50/50.
Step 8 of 12Practice · What would you do?
What would you do?
A spam filter flags emails containing the word "prize." From past data: 20% of all emails are spam, 40% of spam emails contain "prize," and 2% of legitimate emails contain "prize." A new email contains "prize." What is the best estimate of the probability it is spam?
Step 9 of 12Chart
Monty Hall: how often each strategy wins
Staying wins only when your first pick was right (1 time in 3). Switching wins every time it was wrong (2 times in 3).
Step 10 of 12Learn
Thinking like a Bayesian
Bayes' theorem is more than a formula for test results. It is a rule for updating beliefs with evidence, and it captures several habits of clear thinking.
Extraordinary claims need extraordinary evidence. If the prior is tiny, even strong evidence leaves the posterior modest, as with the rare disease. To move a 1-in-a-million prior to likely, you need evidence that is far more probable under the claim than under its alternatives.
Evidence is relative. What matters is the likelihood ratio, P(evidence | A) / P(evidence | not A). The odds form of Bayes makes this explicit:
posterior odds = prior odds × likelihood ratio
For the screening test: prior odds of disease are 1 : 99. The likelihood ratio of a positive result is 0.90 / 0.05 = 18. Posterior odds = 18 : 99 ≈ 1 : 5.5, which is a probability of 18/117 ≈ 15.4%, the same answer as before, with less arithmetic.
Updates chain. Today's posterior is tomorrow's prior, as long as the new evidence is independent given the hypothesis.
Bayesian reasoning powers spam filters, medical decision rules, search-and-rescue planning, A/B test analysis and much of modern machine learning.
Step 11 of 12Practice · Work it out
Prior odds that a coin is a trick two-headed coin are 1 : 9. You flip it 3 times and get 3 heads. The likelihood ratio for this evidence is 1 / (1/8) = 8. What is the posterior probability that the coin is two-headed? Give a decimal to two places.
Step 12 of 12Practice · Choose one
In the Monty Hall game, the host opens a door at random from the two you didn't pick, and by luck it shows a goat. What is your probability of winning if you switch?
Lesson complete!