Distributions
Bayes' Theorem Calculator
Update a probability when evidence arrives — and see why a highly accurate test can still be usually wrong.
How to read this result
The posterior is the answer the evidence gives you. It combines what you believed before (the prior) with how diagnostic the evidence is (the two likelihoods). Neither alone is enough.
The base rate does most of the work, and is what people ignore. With a 1% prior and a test that catches 90% of true cases while producing 9% false positives, a positive result raises the probability to about 9% — not 90%. The reason is arithmetic rather than subtle: among 10,000 people, 90 true positives are swamped by 891 false ones.
The natural-frequency table is the fastest route to intuition. Counting people rather than multiplying probabilities makes the base-rate effect obvious; that reframing was Gigerenzer's finding, and it works on doctors and juries who get the probability version wrong.
The Bayes factor is the evidence on its own. P(B|A) ÷ P(B|not A) says how much the evidence multiplies the odds, independent of the prior. A factor of 10 is strong evidence; it still cannot rescue a prior of one in a million.
The formula
- the prior — the probability before the evidence
- the likelihood — the chance of the evidence if A is true
- the false-positive rate
- the posterior — the probability after the evidence
The denominator is the law of total probability: every route to observing B, weighted by how likely that route is.
Worked example
A screening test for a rare condition
A condition affects 1% of the population. A screening test detects 90% of genuine cases and produces a false positive in 9% of healthy people. Someone tests positive. What is the probability they have the condition?
- Imagine 10,000 people. 1% have the condition.100 have it, 9,900 do not
- Of the 100 who have it, 90% test positive.90 true positives
- Of the 9,900 who do not, 9% test positive anyway.891 false positives
- So 981 people test positive in total.90 + 891 = 981
- Of those, the fraction who actually have it:90 / 981 = 0.0917
Nine times out of ten, a positive result from this test is wrong. The test is not bad — it multiplies the odds by ten — but ten times a very small number is still a small number. This is the base-rate fallacy, and it is why screening programmes are designed around it.
Checked against (0.01 × 0.9) / (0.01 × 0.9 + 0.99 × 0.09), computed directly.
The calculator above is loaded with these numbers by the Load the worked example button.
Assumptions, and when to use something else
The two likelihoods must describe the same evidence, and the prior must be the rate in the population you are actually applying the test to. That last point is where medical examples go wrong in practice: a test's performance is usually measured in a high-prevalence clinical sample and then applied to low-prevalence screening, where the posterior collapses.
The calculator handles a binary hypothesis with binary evidence. Multiple hypotheses or continuous evidence need the general form of the theorem, which is the same idea with a sum or an integral in the denominator.
- You are combining probabilities rather than updating oneProbability calculatorAND, OR, complement and at-least-one rules.
- You want the long-run average of an uncertain quantityExpected valueOutcomes weighted by their probabilities.
- You are testing a hypothesis with dataP-value calculatorThe frequentist counterpart — and note that a p-value is P(data | hypothesis), not P(hypothesis | data), which is exactly the swap this page is about.
Questions people ask
Why is the answer so much lower than the test's accuracy?
Because most people do not have the condition, so most positive results come from the large healthy group even at a low false-positive rate. With a 1% base rate and a 9% false-positive rate, false positives outnumber true ones nearly ten to one. This is the base-rate fallacy.
What is a prior probability?
What you believed before seeing the evidence — usually the base rate in the relevant population. Choosing it is the part of Bayesian reasoning that draws objections, and in diagnostic problems it is often simply known from prevalence data.
What is the difference between P(A|B) and P(B|A)?
Everything, and confusing them is the single most consequential error in applied probability. P(positive | disease) is a property of the test; P(disease | positive) is what the patient wants to know, and the two differ by a factor of ten in the example above. The same confusion turns a p-value into “the probability the null is true”.
Do I need to be a Bayesian to use Bayes' theorem?
No. The theorem is a consequence of the definition of conditional probability and is uncontroversial. Bayesian statistics — putting priors on parameters and updating them with data — is the broader methodology, and this calculator does not require any commitment to it.