Skip to content
K Knidox Search…
Statistics · Probability

Bayes’ Theorem

Update a probability with new evidence, shown both algebraically and as natural frequencies.

Framing
%
P(disease) before any test result is known.
%
Of people who have it, the share the test catches.
%
Of people who do not have it, the share the test correctly clears.
Probability of having it, given a positive test
16.67%A positive result still leaves it more likely than not that they are healthy

Prior was 1% · negative predictive value 99.99%

Out of 10,000 people tested
Test positiveTest negativeTotal
Has it991100
Does not4959,4059,900
Total5949,40610,000

Of the 594 who test positive, 99 actually have it — which is the 16.67% above, read straight off the table.

Bayes’ theorem updates a probability when evidence arrives: P(A|B) = P(B|A)·P(A) ÷ P(B). For a disease affecting 1% of people and a test that is 99% sensitive and 95% specific, a positive result means only a 16.7% chance of actually having it.

Why that answer surprises almost everyone

A test that is 99% accurate at detecting a disease feels conclusive. The reason it is not comes down to how many people are in each group. Out of 10,000 people with a 1% prevalence, 100 have the disease and 9,900 do not. The test catches 99 of the 100 — but it also wrongly flags 5% of the 9,900, which is 495 people. So 594 people test positive and only 99 of them are ill: 16.7%.

The false positives outnumber the true positives simply because the healthy group is a hundred times larger. Neglecting that is the base rate fallacy, and it is the single most common error in reading a test result, made by patients and clinicians alike.

Prior, likelihood, posterior

Three quantities do all the work. The prior is what you believed before the evidence — here the prevalence. The likelihood is how probable the evidence would be if the hypothesis were true — the sensitivity. The posterior is the updated belief. The denominator is just the total probability of seeing that evidence at all, whether the hypothesis holds or not, which is what normalises the result into a proper probability.

P(A|B) = P(B|A)·P(A) ÷ [ P(B|A)·P(A) + P(B|not A)·P(not A) ]

the denominator expands P(B) into the two ways the evidence can arise

  1. 1
    Write down the prior. A prevalence of 1% means P(disease) = 0.01 before testing.
  2. 2
    Find the two ways the evidence can appear. A positive test arises either from a true positive (99% of the 1%) or a false positive (5% of the 99%).
  3. 3
    Compute the numerator. 0.99 × 0.01 = 0.0099 — the probability of being ill and testing positive.
  4. 4
    Compute the total probability of the evidence. 0.0099 + 0.05 × 0.99 = 0.0099 + 0.0495 = 0.0594.
  5. 5
    Divide. 0.0099 ÷ 0.0594 = 0.1667, so about 16.7%.

The same numbers as a count of people

Out of 10,000 tested at 1% prevalence, 99% sensitivity and 95% specificity.

Test positiveTest negativeTotal
Has the disease991100
Does not4959,4059,900
Total5949,40610,000

What changes the answer most

Prevalence dominates. The same test applied to a high-risk group — say 20% prevalence rather than 1% — gives a positive predictive value above 80%, because the diseased group is no longer swamped by false positives. That is precisely why screening tests are targeted at populations where the condition is common, and why a positive result in a general screen is normally followed by a second, more specific test rather than acted on directly.

Specificity matters more than sensitivity here, which is counterintuitive. Raising sensitivity from 99% to 100% adds one true positive out of 594. Raising specificity from 95% to 99% cuts false positives from 495 to 99, which lifts the posterior from 16.7% to about 50%. When the condition is rare, the false-positive rate is what the answer hinges on. Note also that a negative result is very informative in this setting: the negative predictive value is above 99.9%, so the test rules out far better than it rules in.

What does Bayes’ theorem actually do?
It updates a probability in the light of evidence. You start with a prior belief, weigh how likely the evidence would be under each hypothesis, and end with a revised posterior probability.
Why is the answer so low when the test is 99% accurate?
Because the healthy group is far larger. At 1% prevalence, 5% of 9,900 healthy people gives 495 false positives against only 99 true ones, so most positives come from the bigger group.
What is the base rate fallacy?
Judging a test result from its accuracy alone while ignoring how common the condition is. It is what makes a positive result on a rare-disease screen feel far more conclusive than it is.
What is the difference between sensitivity and specificity?
Sensitivity is the share of people with the condition that the test correctly flags. Specificity is the share without it that the test correctly clears. A test can be excellent at one and poor at the other.
Which matters more for a rare condition?
Specificity, usually. When almost everyone is healthy, even a small false-positive rate produces a large number of false positives, so reducing that rate moves the posterior far more than perfecting sensitivity would.
What is positive predictive value?
The probability that someone who tests positive actually has the condition — exactly what Bayes’ theorem computes here. Unlike sensitivity, it depends on prevalence, so the same test has different predictive value in different populations.
Why do doctors repeat a positive screening test?
Because a second, more specific test applied only to those who screened positive starts from a much higher prior. The first test raises the prior from 1% to 16.7%, and the second then operates on that far more favourable base rate.