Bayes' Theorem Calculator
Enter a prior, likelihood and false-positive rate to compute the posterior probability P(A|B). Includes a medical-test preset and a natural-frequency population grid that makes the counter-intuitive results click.
What is Bayes' theorem?
Bayes' theorem is a rule for updating a probability when new evidence arrives. You start with a prior belief P(A), see some evidence B, and end with a posterior belief P(A|B). The formula, the law of total probability that expands the denominator, and the base-rate intuition are all covered in the guide cards below.
Bayes' theorem explained, piece by piece
Each card below owns one part of Bayes' theorem — the formula itself, the law of total probability, the base-rate fallacy, and sequential updating — with a plain-English explanation, the formula (every symbol spelled out), a diagram, and a worked example in one place.
The formula — posterior, likelihood, prior, evidence
Bayes' theorem updates a probability when new evidence arrives. Start with a prior belief P(A), see evidence B, and finish with a posterior P(A|B). The numerator is 'the evidence weighted by the prior'; the denominator normalises by the total probability of the evidence.
Law of total probability — computing P(B)
You never observe P(B) directly. You expand it as 'the two ways B can happen': B with A true (true positives) plus B with A false (false positives). This expansion is what turns the abstract Bayes formula into something you can actually compute.
Base-rate fallacy — why a positive test can still likely be wrong
When the condition is rare, the false-positive count almost always dwarfs the true-positive count. The most accurate way to see this is with natural frequencies: draw a picture of the population and count the boxes rather than juggling percentages.
Sequential updating — the posterior becomes the next prior
Bayes' theorem chains. After one positive test your posterior is (say) 2%. That 2% becomes the prior for the next test. Two independent positive results move you from 0.1% to 2% to well over 30% — this is why confirmatory testing exists.
P(B|A) and P(A|B) are not the same thing
The most common Bayes mistake is treating "probability of a positive test given disease" and "probability of disease given a positive test" as the same number. They are often wildly different, and Bayes' theorem is the exact tool for converting one into the other.
Common mistakes
- Ignoring the base rate. A 99%-accurate test on a 0.1% disease is not "99% likely you have it".
- Swapping P(B|A) and P(A|B). They are different quantities.
- Forgetting the false-positive rate. Without P(B|¬A) you cannot compute P(B), so you cannot apply Bayes.
- Entering percentages as whole numbers. This calculator expects decimals in 0–1.
- Assuming the evidence is decisive. If P(B|A) and P(B|¬A) are close, the test tells you very little.
Features of this calculator
- Inputs for the prior P(A), likelihood P(B|A) and false-positive rate P(B|¬A) — computes the posterior P(A|B) in one click
- Medical-test and spam-filter presets pre-fill realistic numbers you can tweak
- Natural-frequency grid — a 1000-cell population picture with true/false positives and negatives color-coded
- Show/hide step-by-step working: complement, law-of-total-probability expansion for P(B), the Bayes substitution, and a natural-frequency check
- Custom labels — rename A and B so the output reads like your actual problem
- Copy the result summary or download the panel — grid, result and steps — as an image
Frequently asked questions
+What does Bayes' theorem calculate?
The posterior probability P(A|B) — your updated belief that A is true after observing evidence B.
+Do I enter percentages or decimals?
Decimals in the range 0 to 1. 5% is 0.05, not 5.
+What is the law of total probability?
The rule P(B) = P(B|A)·P(A) + P(B|¬A)·P(¬A). It adds the two ways B can happen and gives the denominator of Bayes.
+Why is the natural-frequency picture more intuitive?
Because it converts abstract probabilities into whole-person counts. "50 false positives out of 999 healthy people" is impossible to ignore.
+Can I use Bayes' theorem with more than two hypotheses?
Yes — the general form sums over every mutually exclusive hypothesis in the denominator. This calculator handles the common two-outcome case.