Bayes' Theorem tells us how to update a prior belief when we observe new evidence.
A condition that 1% of people have, and a test that catches 99% of cases with 5% false positives. About 5.9% of everyone tests positive, but only 16.7% of positives are sick — the false positives from the healthy 99% outnumber the true ones. A second, independent positive test lifts it to 79.8%.
- The answer depends heavily on the prior; the same test means different things in a clinic and in a screening of everyone.
- Repeated tests are rarely fully independent; the second update assumes they are.
- People reason much better about this with counts (“10 of 1,000”) than with percentages (Gigerenzer & Hoffrage 1995).
prior = 0.01 # 1% have the condition sens, spec = 0.99, 0.95 # P(+ | sick), P(- | healthy) p_pos = sens * prior + (1 - spec) * (1 - prior) posterior = sens * prior / p_pos # P(sick | +) second = sens * posterior / (sens * posterior + (1 - spec) * (1 - posterior)) # after a second positive test
Assumes import numpy as np. Each snippet carries its own example numbers; the comments say which are made up or simulated.
- T. Bayes, “An Essay towards Solving a Problem in the Doctrine of Chances”, Philosophical Transactions of the Royal Society 53, 1763
- G. Gigerenzer & U. Hoffrage, “How to Improve Bayesian Reasoning without Instruction: Frequency Formats”, Psychological Review 102(4), 1995
- Pattern Recognition and Machine Learning, C. M. Bishop, Springer, 2006
Last reviewed October 2026 · How this site checks its content · Report a mistake
1. A disease affects 1% of people. A test catches 90% of cases and gives a false positive in 9% of healthy people. You test positive. How likely is it that you have the disease?
Show answer
A. Of 1,000 people, 9 sick ones test positive and about 89 healthy ones do too: 9 / 98 ≈ 9%. The low base rate dominates.
2. When does the prior matter most in a Bayesian analysis?
Show answer
C. With much data the likelihood overwhelms any reasonable prior; with little data the prior can decide the answer.
3. What does a naive Bayes classifier assume?
Show answer
C. The assumption is rarely true, yet the classifier often ranks well — its probabilities, though, tend to be overconfident.