Bayes' theorem, explained with one clear example
6 min read
Short answer
Bayes' theorem turns into : In words: start from how common is, then update it by how well points to . The easiest way to apply it is to imagine 10,000 people and count.
The idea in one sentence
"Given that the test is positive, how likely is it that I'm sick?" is a different question from "if I'm sick, how likely is a positive test?" Bayes' theorem converts one into the other, and the missing ingredient is the base rate, how common the condition was in the first place.
Count instead of plug in
Natural frequencies avoid most errors. Pick a round population, split it by the base rate, apply the test's rates to each group, and then look only at the people who tested positive. The answer is the share of those positives who really have the condition.
Worked example
A disease affects 1% of people. A test detects it in 90% of sick people (sensitivity) but also gives a false positive for 9% of healthy people. You test positive. What is the probability you are sick?
Imagine 10,000 people.
- Sick: . Of these, test positive: 90.
- Healthy: . Of these, test positive: 891.
Positives in total: . So
With the formula: and . Same result: a positive test raises the chance from 1% to about 9%, far below 90%.
Try it yourself
5% of items from a factory are defective. An inspector flags 95% of defective items and also 10% of good ones. An item is flagged. What is the probability it is defective?
Show the answer
Take 2,000 items: 100 defective and 1,900 good. Flagged defective: . Flagged good: . So .
Keep going with practice
Conditional probability and Bayes' theorem are part of Vidi's Linear Algebra & Probability course, with auto-graded practice like the problem above.