Bayes' Theorem and the Medical Testing Paradox
Why a highly accurate medical test can still be wrong more often than right when the disease it screens for is rare, worked through with Bayes' theorem step by step.
Bayes' theorem, stated and derived
Bayes' theorem is a direct algebraic consequence of the definition of conditional probability, but its implications are so counterintuitive that it deserves its own careful treatment. Starting from the multiplication rule, P(A ∩ B) can be written two equivalent ways: P(A | B)P(B) and P(B | A)P(A). Setting these equal and dividing through by P(B) gives
P(A | B) = P(B | A) · P(A) / P(B)
In words: the probability of A given that B occurred equals the probability of B given A, times the prior probability of A, divided by the overall probability of B. The three named quantities in this formula are the prior P(A), the likelihood P(B | A), and the posterior P(A | B); the denominator P(B) is usually called the evidence or marginal likelihood, and its job is purely to rescale the numerator so that the resulting posterior probabilities are properly normalised across all possible values of A.
The classic medical test example, worked in full
Suppose a disease affects 1% of a population (its prevalence, P(Disease) = 0.01). A screening test has sensitivity 90% — it correctly returns positive for 90% of people who truly have the disease, so P(Positive | Disease) = 0.90 — and specificity 95%, meaning it correctly returns negative for 95% of healthy people, so P(Negative | No Disease) = 0.95, equivalently P(Positive | No Disease) = 0.05, the false positive rate.
A patient tests positive. What is the probability they actually have the disease? First compute the total probability of a positive result across the whole population, using the law of total probability: P(Positive) = P(Positive | Disease)P(Disease) + P(Positive | No Disease)P(No Disease) = (0.90 × 0.01) + (0.05 × 0.99) = 0.009 + 0.0495 = 0.0585. Then apply Bayes' theorem: P(Disease | Positive) = (0.90 × 0.01) / 0.0585 = 0.009 / 0.0585 ≈ 0.154, or about 15.4%.
Despite a test that sounds highly accurate on both dimensions, a positive result only raises the probability of disease from a 1% prior to about a 15% posterior — nowhere near certainty. The intuitive error most people make is to mentally substitute the sensitivity (90%) for the answer, effectively confusing P(Positive | Disease) with the very different quantity P(Disease | Positive).
Why rarity dominates the arithmetic
The reason is entirely about base rates. Out of 10,000 people in this population, about 100 truly have the disease, and the test correctly flags roughly 90 of them. But among the 9,900 healthy people, the 5% false positive rate still produces about 495 false alarms. The pool of positive results (90 + 495 = 585 people) is therefore dominated by false positives from the much larger healthy population, even though each individual healthy person only had a small 5% chance of a false alarm. This "counting the population" approach — sometimes called natural frequency reasoning — is often far more intuitive for people than working directly with the Bayes' theorem formula, while giving exactly the same numerical answer: 90 out of 585 positives are true positives, which is 90/585 ≈ 0.154, matching the formula exactly.
Prior distributions and updating with new evidence
Bayes' theorem does not stop after one update. If the same patient is retested with an independent second test, the posterior from the first test (15.4%) becomes the prior for interpreting the second result, and the calculation repeats. This sequential updating is the core idea of Bayesian statistics: rather than treating a probability as a single value to estimate and lock in, it is treated as a belief that gets systematically revised as evidence accumulates, converging toward the truth as more independent evidence is gathered.
In more general Bayesian statistical modelling, the prior is not just a single number like disease prevalence but an entire prior distribution over an unknown parameter — for example, a range of plausible values for a drug's true effectiveness before a clinical trial begins, often represented with a Beta distribution when the parameter is a probability between 0 and 1. Combining that prior distribution with the likelihood of the observed trial data, again via Bayes' theorem, produces a full posterior distribution over the parameter, which captures not just a best estimate but the remaining uncertainty around it, in a mathematically consistent way that classical hypothesis testing does not naturally provide.
Beyond medicine: the same logic in finance and elsewhere
Exactly the same structure recurs anywhere a signal with imperfect accuracy is used to detect a rare underlying condition. A fraud-detection algorithm flagging a transaction, a credit model flagging a loan default risk, a spam filter flagging an email, or an airport security system flagging a passenger all face the identical mathematics: if the underlying event being detected is rare, even a highly accurate detector will produce a substantial share of false alarms relative to true detections, and the posterior probability that a flagged case is genuine must be computed with the true base rate in mind, not read off directly from the detector's advertised accuracy. This is precisely why, in practice, Bayesian reasoning is standard in fields like clinical diagnostics, quantitative finance risk modelling, and machine learning classifier evaluation, wherever decisions hinge on rare-event probabilities.
Frequently Asked Questions
Does a negative test result mean the patient definitely does not have the disease?
No, though it is close in this example. Using the same numbers, P(No Disease | Negative) can be computed the same way: P(Negative) = (0.10 × 0.01) + (0.95 × 0.99) = 0.001 + 0.9405 = 0.9415, and P(Disease | Negative) = (0.10 × 0.01)/0.9415 ≈ 0.00106, about 0.1%. So a negative result is reassuring and correctly lowers the probability of disease well below the 1% prior, but it is not absolute certainty.
What would happen to the posterior if the disease were more common, say 20% prevalence, instead of 1%?
Using the same sensitivity and specificity: P(Positive) = (0.90 × 0.20) + (0.05 × 0.80) = 0.18 + 0.04 = 0.22, so P(Disease | Positive) = 0.18/0.22 ≈ 0.818, about 82%. The identical test becomes far more trustworthy simply because the disease is more common in the tested population — the same test, radically different real-world reliability, purely as a function of the prior.
Why do doctors sometimes order a second, different test after a positive screening result?
Because sequential Bayesian updating compounds evidence multiplicatively. A confirmatory test, especially one with a different, largely independent source of error from the first, sharply raises the posterior probability further, which is exactly why many screening programmes use a cheap, high-sensitivity initial test followed by a more expensive, high-specificity confirmatory test rather than relying on a single test alone.
Is Bayesian statistics the opposite of traditional ('frequentist') statistics?
They are two different frameworks built on the same Kolmogorov axioms, not opposing mathematics. Frequentist methods treat parameters as fixed unknown constants and probability as long-run frequency; Bayesian methods treat parameters as having a probability distribution reflecting uncertainty, updated via Bayes' theorem as data arrives. In practice, with large amounts of data and a suitably uninformative prior, the two approaches typically converge to very similar numerical conclusions.