One thousand people take a test. Red dots are sick and test positive, amber dots are healthy but test positive. Move the prevalence, sensitivity and specificity sliders and watch how many of the positives are real.
← All labsBased on Chapter 2, Bayes' Rule, of Polson and Sokolov, Bayes, Artificial Intelligence, and Deep Learning (vsokolov.org/html/_book).
The jar also holds one two-headed coin. You draw one coin at random and flip it. Every flip so far came up heads.
| Heads in a row, k | 0 |
| Prior odds, two-headed : fair | – |
| Likelihood ratio, 2k : 1 | – |
| Posterior odds | – |
| P(two-headed | k heads) | – |
Each head is a "positive test" with sensitivity 1 (a two-headed coin always lands heads) and a false-positive rate of 1/2 (a fair coin lands heads half the time). The posterior reaches 50/50 when the evidence 2k matches the prior odds against, 1,024 : 1 at k = 10.
A test result is evidence, not a verdict. The posterior depends on three numbers, and the base rate is the one people forget. When a condition is rare, even a small false-positive rate applied to the large healthy group produces more false alarms than the test finds real cases.
With prevalence 1%, 10 women like Alice have cancer and 990 do not. This split is the prior, before anyone is tested.
Sensitivity 80% finds 8 of the 10 cancers. A false-positive rate of 10% flags 99 of the 990 healthy women. That gives 107 positive mammograms.
Keep only the 107 positives. Of these, 8 have cancer, so P(cancer | positive) = 8 / 107 ≈ 7.5%. A positive mammogram still leaves Alice about 92% likely to be healthy.
A second positive starts from 7.5% instead of 1% and moves the posterior to 39%. A third moves it to 84%. Repeated evidence can overcome a low prior, as long as the tests make independent errors.
Takeaway for students. "98% accurate" describes P(test | truth). The decision needs P(truth | test). Bayes' rule converts one into the other, and the conversion runs through the base rate. Without the prior you cannot interpret the test.