Bayes' theorem and the 99%-accurate test
A disease affects 1 in 1,000 people. A test for it is 99% accurate: it catches 99% of sick people and wrongly flags only 1% of healthy ones. You test positive. What is the chance you actually have the disease?
Most people, including many doctors in published surveys, answer "about 99%". The real answer is about 9%. Bayes' theorem explains the gap, and once you see it you will spot the same mistake in spam filters, fraud alerts and security screening.
Count people, not probabilities
The quickest way to the right answer is to imagine a concrete crowd. Take 100,000 people and follow them through the test.

- 100 of them have the disease (0.1%). The test catches 99 and misses 1.
- 99,900 are healthy. The test wrongly flags 1% of them, which is 999 people.
- That makes 1,098 positive results in total, and only 99 of them are real.
So if you are one of the 1,098 people holding a positive result, your chance of being sick is:
The test is excellent. The trouble is that healthy people outnumber sick people 999 to 1, so even a 1% error rate on the healthy group produces ten times more false alarms than there are real cases.
When a condition is rare, false positives can outnumber true positives, even with a very accurate test.
The theorem
Bayes' theorem is the same calculation written in symbols. Let mean "has the disease" and mean "tests positive":
The denominator counts every way to get a positive result, true or false:
Each piece has a name and a job:

| Term | Name | In our example |
| Prior: what you believed before the test | (prevalence) | |
| Likelihood: how well the test detects the disease | (sensitivity) | |
| False-positive rate, equal to 1 minus the specificity | ||
| Evidence: how common a positive result is overall | ||
| Posterior: what you should believe after the test |
Plug in the numbers
This is exactly from the crowd of 100,000, just divided through by the population size.
The error people make is to confuse with . The first is "how likely is a positive, given that you are sick" (99%). The second is "how likely are you sick, given a positive" (9%). They sound alike, and they can be wildly different.
The prior changes everything
The same test gives very different answers depending on who takes it. Here is for the same 99%-sensitive, 1%-false-positive test at different prevalences:
| Prevalence | Who might be tested | |
| 0.1% | Random screening of the public | 9% |
| 1% | A higher-risk group | 50% |
| 10% | Patients with symptoms | 92% |
| 50% | Patients the doctor strongly suspects | 99% |
This is why doctors test people with symptoms rather than everyone, and why a positive screening result is usually followed by a second, different test.
Test again: odds make it easy
Bayes' theorem is cleanest in odds form. Odds are the ratio of "yes" to "no": a probability of 0.1% is odds of 1 to 999. Then:
For our test the likelihood ratio is . Every positive result multiplies the odds by 99, as long as the tests are independent given your true condition:

- Before testing: odds , so .
- After one positive: , so .
- After two positives: , so .
- After three positives: about , so .
You can reach the second result directly by using the first posterior as the new prior:
Today's posterior is tomorrow's prior. That one sentence is the whole of Bayesian updating.
What about a negative result?
The same arithmetic shows why a negative result is very reassuring here. Of the 98,902 people who test negative, only 1 is sick:
A rare disease and an accurate test make negatives highly trustworthy and positives surprisingly weak. Both facts come from the same base rate.
In Python
def posterior(prior, sensitivity, false_positive_rate):
true_pos = sensitivity * prior
false_pos = false_positive_rate * (1 - prior)
return true_pos / (true_pos + false_pos)
p = 0.001
for test in range(1, 4):
p = posterior(p, sensitivity=0.99, false_positive_rate=0.01)
print(f"after positive test {test}: {p:.1%}")
# after positive test 1: 9.0%
# after positive test 2: 90.8%
# after positive test 3: 99.9%Key takeaways
- and are different questions. Mixing them up is called the base-rate fallacy.
- For rare conditions, false positives from the large healthy group can swamp the true positives.
- Thinking in natural frequencies (counting people out of 100,000) makes the answer obvious.
- In odds form, each piece of independent evidence multiplies your odds by its likelihood ratio.
- The posterior from one test becomes the prior for the next.