Bayes' Theorem
Bayes' theorem flips a conditional probability around: from "how likely is a positive test if you're sick?" to "how likely are you sick if you tested positive?" Those can be wildly different, because the answer also depends on how common the disease was to begin with.
What the symbols mean
- Posterior
The updated probability of A after seeing B.
- Likelihood
How probable the evidence B is if A is true.
- Prior
The probability of A before the evidence (the base rate).
- Evidence
The overall probability of seeing B.
Explanation
Bayes' theorem is simply a rule for updating a probability when you get new evidence, named after Thomas Bayes, the English minister who first worked it out. It looks like a jumble of conditionals, but it's a fraction with a clear story: on top, (how likely the evidence is if is true) times (how likely was before you saw anything); on the bottom, (how likely the evidence is overall). The total-probability line just computes that bottom by adding up the two ways can happen, with and without it. It's nothing more than the multiplication rule rearranged, so hang in there.
Where it comes from. You already know . But you could just as well write it the other way: . Set the two equal and divide by , and that's Bayes' theorem.
Medical tests. Suppose 1% of people have a disease, the test catches 95% of cases (sensitivity), and it wrongly flags 5% of healthy people (false positive rate). It's easiest to think in people rather than formulas. Out of 10,000 people:
- 100 are sick, and 95 of them test positive.
- 9,900 are healthy, and 495 of them test positive.
So . Think about why it's so low. The test is good, but the healthy group is 99 times bigger than the sick group, so even its small 5% error rate produces five times as many false alarms as true positives.
A common mistake. It's tempting to think a 95% accurate test means a positive result is 95% likely to be right. That ignores the prior, how common the disease is, and it's called the base-rate fallacy. A test's accuracy alone doesn't tell you what a positive result means; you need to know how common the condition is.
See it
Worked examples
With prevalence 1%, sensitivity 95% and false positive rate 5%, find .
- 1
A positive can come from a sick person or a healthy one, so add both: .
Practice
Type your answer and check it. Solve them all to complete the lesson.
With prevalence 1%, sensitivity 95% and false positive rate 5%, find .
Find .
If the prevalence is 10% instead, find .
Machine A makes 60% of parts (2% defective) and machine B 40% (5% defective). Given a part is defective, find .
Why is a positive test for a rare disease often a false alarm?
One email in 5 is spam. The word "winner" appears in 40% of spam and in 2% of legitimate email. An email contains "winner." What's the probability it's spam?
A disease has prevalence 1%, and a test has 95% sensitivity and a 5% false positive rate. After one positive test the probability of disease is about 0.161. The patient is retested independently and is positive again. What's the probability of disease now?
The hardest one here. Get it, and you've got this lesson.
On a game show you pick door 1 of 3; one hides a car, the others goats. The host, who knows where the car is and always opens a goat door you didn't pick, opens door 3. What's the probability the car is behind door 2?
Where it's used
Spam filters, medical diagnosis, search-and-rescue planning and machine learning classifiers all update probabilities with Bayes' theorem.