Virtual laboratory/Mathematics/Probability/Bayes' Theorem — the Test Paradox

Bayes' Theorem — the Test Paradox

An extension of the topic of conditional probability. Even a very accurate test for a rare disease produces plenty of false alarms — a positive result may indicate a low probability of disease. Bayes' theorem: P(A|B)=P(B|A)·P(A)/P(B) — the probability depends on the base rate too, not only on the test's sensitivity. It was formulated by Thomas Bayes (published posthumously in 1763).

Bayes' Theorem — the Test Paradox
Mathematics · Probability · Bayes’ theorem — the test paradox (1763)
Disease prevalence in the population P(disease)P(\text{disease})2.0 %
A positive result from an accurate (99%) test for a very rare disease most likely means that…
base rate
2.0%
true positive
1,980
false positive
980
P(disease | +)
67%
🎯 Challenge: hit P(disease | +)
streak: 0

I’ll give you a target P(disease | +) — use the slider to set the base rate so the Bayes posterior hits it. Same test (99%), different result.

What just happened?

Even a very accurate test (99% sensitivity and specificity) for a rare disease produces plenty of false alarms. The reason: for a rare disease the number of healthy people is huge, so a small percentage of false positives among the healthy outweighs the true positives among the few sick. That is why a positive result often means a low probability of disease.

Bayes’ theorem:

P(A∣B)=P(B∣A) P(A)P(B)P(A\mid B)=\dfrac{P(B\mid A)\,P(A)}{P(B)}

— describes how to update the probability of a hypothesis AA in light of new data BB. In diagnostics: AA = "disease", BB = "positive result".

Numeric example (per 100,000 people):

P(d∣+)=P(+∣d) P(d)P(+∣d) P(d)+P(+∣h) P(h)P(\text{d}\mid+)=\dfrac{P(+\mid\text{d})\,P(\text{d})}{P(+\mid\text{d})\,P(\text{d})+P(+\mid\text{h})\,P(\text{h})}

At a prevalence of 0.1%0.1\%: 100100 sick → the test detects 9999; among 99 90099\,900 healthy people, 1%1\% false positives is 999999 people. Out of 10981098 positives only 9999 are truly sick, so P(d∣+)=991098≈9%P(\text{d}\mid+)=\tfrac{99}{1098}\approx 9\%. The probability depends also on the base rate, not only on the test accuracy.

Why does this work? (the invariant)

Ignoring the base rate (prevalence) is the classic "base-rate fallacy" — common even among doctors. The probability of disease given a positive result depends also on how common the disease is in the population, not solely on the sensitivity and specificity of the test. For a rare disease the false positives dominate; the more common the disease, the larger the share of truly sick among all positives (the gauge P(d∣+)P(\text{d}\mid+) rises).

History and applications

The theorem was formulated by Thomas Bayes, and his work was published posthumously in 1763. It is the foundation of Bayesian statistics, medical diagnostics, spam filters, machine learning, and rational inference. It teaches us not to trust "test accuracy" blindly without asking: how common is the thing being tested for?

Why you need this for the exam:

This extends conditional probability. Trick: write out concrete counts over a large population (e.g. 100,000) and count how many are true and false positives — then you compute P(A∣B)P(A\mid B) directly from the definition, with no base-rate fallacy.

Remember: a positive result from an accurate test for a rare disease usually means you are healthy anyway — because false alarms predominate. Always ask about the base rate before trusting "test accuracy".

Illustrative model · NexTutor Virtual Laboratory

Enjoyed the experiment? Share it.

It's free — send it to friends from school.

Theory & formulas

Bayes' formula

P(A∣B)=P(B∣A) P(A)P(B)P(A\mid B)=\frac{P(B\mid A)\,P(A)}{P(B)}

The test paradox

For a rare disease (small P(A)P(A)) even a sensitive test produces many false alarms — a positive result may indicate a low probability of disease.

The base-rate fallacy

Ignoring the prevalence P(A)P(A) (how common the disease is in the population) inflates the estimate — a common mistake, even among doctors.

Notation: P(A)P(A) is the prior probability, P(A∣B)P(A\mid B) the posterior, P(B∣A)P(B\mid A) the test's sensitivity.

Frequently asked questions

›

What does a positive result from a test for a very rare disease mean?

Most often, that you are healthy — because false positives among the many healthy people outnumber the truly sick.

›

What does the probability of disease given a positive result depend on?

On the test's sensitivity AND on the disease's base rate in the population (not only on the test's accuracy).

›

What is the base-rate fallacy?

Omitting the disease's prevalence when interpreting a test result — a classic mistake, common even among doctors.

Teaching? Embed this experiment on your site.

Free widget — paste it on your school site, blog or notes. It links to the full version.

Teaching a class or tutoring? Guide students in NexTutor →