Octonote AI
Make your own →

Note

Bayes' theorem and the 99%-accurate test

Sunil Tiwari· Oct 12, 2026 · 5 min

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,000 people take a 99%-accurate test
100,000 people take a 99%-accurate 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:

991,098≈0.090=9%\frac{99}{1{,}098} \approx 0.090 = 9\%

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 DD mean "has the disease" and ++ mean "tests positive":

P(D∣+)=P(+∣D) P(D)P(+)P(D \mid +) = \frac{P(+ \mid D)\, P(D)}{P(+)}

The denominator counts every way to get a positive result, true or false:

P(+)=P(+∣D) P(D)+P(+∣¬D) P(¬D)P(+) = P(+ \mid D)\,P(D) + P(+ \mid \neg D)\,P(\neg D)

Each piece has a name and a job:

The four parts of Bayes' theorem
The four parts of Bayes' theorem
TermNameIn our example
P(D)P(D)Prior: what you believed before the test0.0010.001 (prevalence)
P(+∣D)P(+ \mid D)Likelihood: how well the test detects the disease0.990.99 (sensitivity)
P(+∣¬D)P(+ \mid \neg D)False-positive rate, equal to 1 minus the specificity0.010.01
P(+)P(+)Evidence: how common a positive result is overall0.010980.01098
P(D∣+)P(D \mid +)Posterior: what you should believe after the test≈0.09\approx 0.09

Plug in the numbers

P(D∣+)=0.99×0.0010.99×0.001+0.01×0.999=0.000990.00099+0.00999=0.000990.01098≈9.0%P(D \mid +) = \frac{0.99 \times 0.001}{0.99 \times 0.001 + 0.01 \times 0.999} = \frac{0.00099}{0.00099 + 0.00999} = \frac{0.00099}{0.01098} \approx 9.0\%

This is exactly 99/1,09899 / 1{,}098 from the crowd of 100,000, just divided through by the population size.

The error people make is to confuse P(+∣D)P(+ \mid D) with P(D∣+)P(D \mid +). 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 P(D∣+)P(D \mid +) for the same 99%-sensitive, 1%-false-positive test at different prevalences:

Prevalence P(D)P(D)Who might be testedP(D∣+)P(D \mid +)
0.1%Random screening of the public9%
1%A higher-risk group50%
10%Patients with symptoms92%
50%Patients the doctor strongly suspects99%

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:

P(D∣+)P(¬D∣+)⏟posterior odds=P(D)P(¬D)⏟prior odds×P(+∣D)P(+∣¬D)⏟likelihood ratio\underbrace{\frac{P(D \mid +)}{P(\neg D \mid +)}}_{\text{posterior odds}} = \underbrace{\frac{P(D)}{P(\neg D)}}_{\text{prior odds}} \times \underbrace{\frac{P(+ \mid D)}{P(+ \mid \neg D)}}_{\text{likelihood ratio}}

For our test the likelihood ratio is 0.99/0.01=990.99 / 0.01 = 99. Every positive result multiplies the odds by 99, as long as the tests are independent given your true condition:

Each positive test multiplies the odds by 99
Each positive test multiplies the odds by 99
  • Before testing: odds 1:9991 : 999, so P=0.1%P = 0.1\%.
  • After one positive: 99:999≈1:1099 : 999 \approx 1 : 10, so P≈9%P \approx 9\%.
  • After two positives: 9,801:999≈10:19{,}801 : 999 \approx 10 : 1, so P≈91%P \approx 91\%.
  • After three positives: about 971:1971 : 1, so P≈99.9%P \approx 99.9\%.

You can reach the second result directly by using the first posterior as the new prior:

P(D∣++)=0.99×0.09020.99×0.0902+0.01×0.9098≈91%P(D \mid ++) = \frac{0.99 \times 0.0902}{0.99 \times 0.0902 + 0.01 \times 0.9098} \approx 91\%

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:

P(D∣−)=0.01×0.0010.01×0.001+0.99×0.999≈0.001%P(D \mid -) = \frac{0.01 \times 0.001}{0.01 \times 0.001 + 0.99 \times 0.999} \approx 0.001\%

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

  • P(+∣D)P(+ \mid D) and P(D∣+)P(D \mid +) 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.
Was this useful?
Written bySunil Tiwari
Make a page like this. Free.Notes and diagrams side by side, written by you or by Claude Code and Codex. Publish it in one click.
Make your own, free