Understanding Bayes' Theorem
Bayes' Theorem (test / evidence form):
P(A|B) = P(B|A) × P(A) / [ P(B|A) × P(A) + P(B|¬A) × (1 − P(A)) ]
Turns a prior probability P(A) into a posterior P(A|B) after observing evidence B
Bayes' theorem tells you how to revise a probability when new evidence arrives. You start with a prior P(A) — your best estimate before the evidence, usually the base rate in the population. Evidence B (a positive test, a symptom, a measurement) then shifts that estimate to a posterior P(A|B). The theorem is the exact rule for that update, and it is nothing more than the definition of conditional probability rearranged: P(A|B) = P(A and B) / P(B).
The denominator P(B) is the total probability of seeing the evidence, whether or not the hypothesis is true. It has two sources: true positives from the P(A) fraction of cases where the hypothesis holds, and false positives from the (1 − P(A)) fraction where it does not. Writing it out gives the expanded form this calculator uses.
What each input means
- Prior P(A): the base rate — how common the condition or hypothesis is before you look at the evidence. For a disease it is the prevalence; for a spam filter it is the fraction of email that is spam.
- Sensitivity P(B|A): the true positive rate — the probability the evidence appears when the hypothesis is true. A test with 99% sensitivity flags 99 of every 100 true cases.
- False positive rate P(B|¬A): the probability the same evidence appears when the hypothesis is false. It equals 1 − specificity. A test with 95% specificity has a 5% false positive rate.
Worked example: the rare-disease trap
Suppose a disease has a prevalence of 1% (prior = 0.01), the test has 99% sensitivity, and a 5% false positive rate. Out of 10,000 people, 100 have the disease and 99 test positive. Of the 9,900 healthy people, 5% — that is 495 — also test positive. So 99 + 495 = 594 people test positive, but only 99 truly have the disease. The posterior is 99 / 594 ≈ 16.7%. A "99% accurate" positive test still leaves a better-than-4-in-5 chance the person is healthy, because the healthy group is so much larger. This is base rate neglect, and it is the single most common mistake in reading test results.
The likelihood ratio
The ratio sensitivity ÷ false-positive-rate is the Bayes factor (likelihood ratio) for a positive result. It measures how much the evidence favors the hypothesis, independent of the prior. A likelihood ratio of 1 means the evidence is useless — it is equally likely under both hypotheses, so the posterior equals the prior. Ratios above 1 push the probability up; ratios below 1 push it down. In odds form, Bayes' theorem is simply: posterior odds = prior odds × likelihood ratio.