Bayes' Theorem Calculator

Update a prior probability with new evidence. Enter the prior, the sensitivity (true positive rate), and the false positive rate to get the posterior probability P(A|B).

Quick Facts

Method
P(A|B) = P(B|A)·P(A) / [P(B|A)·P(A) + P(B|¬A)·(1−P(A))]
Exact Bayesian update — no approximation or rounding in the math.

Your Results

Calculated
Posterior probability P(A|B)
-
Chance the hypothesis is true given the evidence
Total evidence probability P(B)
-
Overall chance of a positive result
Bayes factor / likelihood ratio
-
Sensitivity ÷ false positive rate
Interpretation
-
How strongly the evidence updates the prior

Ready

Enter a prior, sensitivity, and false positive rate, then calculate.

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.

Frequently Asked Questions

Why is the posterior so low even when the test is 99% accurate?
Because of the base rate. When the condition is rare, the large healthy group produces many false positives that outnumber the true positives. With a 1% prior, 99% sensitivity, and a 5% false positive rate, a positive result means only about a 16.7% chance of actually having the condition. Lowering the false positive rate (raising specificity) is what makes a positive result trustworthy for rare conditions.
What is the difference between the prior and the posterior?
The prior P(A) is your probability before seeing the evidence — normally the base rate. The posterior P(A|B) is the updated probability after the evidence. Bayes' theorem is the rule that converts one into the other using the sensitivity and false positive rate.
How do I get the false positive rate from specificity?
False positive rate = 1 − specificity. A test that is 95% specific has a 5% false positive rate; a 99% specific test has a 1% false positive rate. Enter that value as a percentage in the third field.
Can I use this for things other than medical tests?
Yes. Any time you update a probability with imperfect evidence the same math applies: spam filtering (prior = fraction of spam, evidence = a keyword), quality control (prior = defect rate, evidence = a failed inspection), or forecasting (prior = base rate of an outcome, evidence = an indicator). Map your situation to prior, sensitivity, and false positive rate.