Bayes' Theorem Calculator
Result
Posterior probability P(A|E)
- Probability that A is false P(¬A|E)
- 84.62%
- Probability of the evidence P(E)
- 5.85%
- Change from prior to posterior (percentage points)
- 14.38
A Bayes' theorem calculator turns a belief you held before seeing anything into the belief you should hold after seeing it. Give it the prior probability of a condition, the chance the evidence appears when the condition is present, and the chance the evidence appears when it is not, and it returns the posterior probability of the condition given the evidence — along with the complementary probability, the overall chance of seeing that evidence at all, and how many percentage points the belief moved. The setting that makes this worth calculating rather than guessing is a rare condition with an imperfect test: with a 1% prevalence, a 90% detection rate and a 5% false positive rate, a positive result raises the probability of the condition to about 15%, not to ninety. Tests change belief by less than intuition suggests whenever the thing being tested for is uncommon.
Formula
P(A | E) = P(E | A) · P(A) / [ P(E | A) · P(A) + P(E | ¬A) · P(¬A) ]
- P(A)
- The prior probability of the condition, entered as a percentage — what you believed before the evidence arrived. It carries more weight than people expect: when it is small, it takes a great deal of evidence to move it far
- P(E | A)
- The probability of seeing the evidence when the condition is present. In a test this is the detection rate, or sensitivity — the share of true cases the test catches
- P(E | ¬A)
- The probability of seeing the same evidence when the condition is absent. In a test this is the false positive rate, and it is the term that does most of the damage when it is not small
- P(¬A)
- The probability the condition is absent, which is 100% minus the prior. The denominator adds the two ways the evidence can appear, weighted by how common each state is
- P(E)
- The overall probability of the evidence, appearing in the population regardless of whether the condition holds. It is the denominator, and the panel reports it on its own because a small value here is what makes the posterior move sharply
- P(A | E)
- The posterior probability: the belief after the evidence. The result panel also reports its complement, since "the test was positive and there is still an 85% chance of not having it" is often the sentence that actually communicates the number
Use it whenever a test result has to be read against how common the thing being tested for actually is: a screening test in a low-prevalence population, a spam filter reading a word, a diagnostic check on a rare fault, or any situation where a positive result is being treated as proof. It is also the right tool for the reverse question — working out how good a test needs to be before a positive result means anything, which is usually a far more useful number than the posterior for one particular prior. Reach for it when you have a prior worth stating; when you have no idea what the prior should be, the honest answer is that the posterior will be dominated by that ignorance, and the panel can show you exactly how much.
Worked examples
A 1% condition, a 90% detection rate and a 5% false positive rate
- Take 10000 people: about 100 have the condition and 9900 do not
- Of the 100 with it, 90% test positive, so about 90 true positives
- Of the 9900 without it, 5% also test positive, so about 495 false positives
- A positive result therefore comes from 90 + 495 = 585 people, and 90 / 585 = 15.38%
This is the case the whole page is built around, and the arithmetic in the steps is why. Counting people makes the mechanism visible: the false positive rate is applied to a group ninety-nine times larger than the group with the condition, so it produces five and a half times as many positives as the detection rate does. The posterior of 15.38% is not a statement that the test is bad — a 90% detection rate is good — it is a statement that the condition was rare enough for the errors to outnumber the successes. The complementary 84.62% says the same thing from the other side, and the shift of 14.38 percentage points is what one test of this quality is actually worth here.
A 2% condition and a 99% accurate test
- Take 10000 people: about 200 have the condition and 9800 do not
- Of the 200 with it, 99% test positive: about 198 true positives
- Of the 9800 without it, 1% still test positive: about 98 false positives
- A positive result comes from 198 + 98 = 296 people, and 198 / 296 = 66.89%
Even a test that is wrong only one time in a hundred leaves a third of its positive results wrong, because it is applied to a group that is forty-nine times larger. Raise the accuracy to 99.9% against the same 452 people per 10000 and the posterior climbs past 95% — which shows the two levers are not interchangeable. The detection rate sets how many true positives you get, and the false positive rate sets how much noise they are buried in; improving the second usually buys far more than improving the first, and this example is the cheapest way to see that before commissioning a better test.
Evidence that argues against the condition
- Starting from an even prior: 50% for the condition and 50% against
- The evidence is five times more likely when the condition is absent (90% versus 5%)
- The denominator is 0.05 × 0.5 + 0.9 × 0.5 = 0.475, so the evidence itself is fairly likely
- The posterior is 0.025 / 0.475 = 5.26%, a fall of 44.74 percentage points
The negative shift is the part worth pausing on, and the part that the percentage-point unit exists for. A fall from 50% to 5.26% is a drop of 44.74 percentage points; it is not a fall of 44.74%, which would mean the posterior had landed at about 27.6%. Reading the shift as a relative change is the standard way to misquote this panel, and the sign is what tells you the evidence pointed the other way. Note too that the evidence here is unremarkable — a 47.5% chance of appearing at all — while still being strongly informative, because informativeness comes from the ratio between the two likelihoods rather than from the evidence being rare.
Limitations
The posterior is only as good as the three numbers you enter, and the prior is the one people are most tempted to invent. When the condition is rare, the posterior is dominated by the prior and by the false positive rate, so an optimistic guess at either produces a confident and wrong answer — the panel cannot tell you that your prior was a guess. Two further cautions. The likelihoods are treated as exact, so a detection rate quoted from a small validation study is being used at a precision it does not have. And the calculation is for one piece of evidence read once: applying the same test twice is not the same as applying two independent tests, because a second result from the same imperfect instrument is correlated with the first — feeding the posterior back in as a new prior will overstate how much the second test adds. When the evidence is impossible under every state — both likelihoods at 0%, or a 0% false positive rate against a 0% prior — the denominator is zero and there is no posterior to report, because conditioning on something that cannot happen is not a question with an answer.
Frequently asked questions
- Why does a 90% accurate test give only a 15% chance of having the condition?
- Because accuracy on the people who have it and accuracy on the people who do not are two different numbers, and the second one gets multiplied by a much larger group. With a 1% prevalence, the people without the condition outnumber those with it ninety-nine to one, so a 5% false positive rate produces hundreds of false positives where a 90% detection rate produces tens of true positives. The test is doing its job; the condition is simply rare enough that its errors outnumber its catches. This is the base rate at work, and it is why the prior is a required input rather than an afterthought.
- What are the percentage points in the shift row?
- They are the difference between the prior and the posterior, measured in percentage points rather than as a relative change. Going from 50% to 5.26% is a shift of −44.74 percentage points; it is not a fall of 44.74%, which would mean the posterior had landed near 27.6%. The distinction matters most for large moves, where the relative reading is wildly wrong, and the sign is what tells you which way the evidence pushed — a negative shift means the evidence argued against the condition.
- Can I use the posterior as the prior for the next test?
- Only if the second piece of evidence is genuinely independent of the first. Two results from the same test are not independent: a false positive on one run makes a false positive on the next more likely, because the instrument has the same flaw both times. Feeding the posterior back in as a new prior anyway will overstate what the second result adds — sometimes by a lot. When the evidence really is independent, updating in two steps gives the same answer as updating once with both pieces at the same time, so the shortcut is safe exactly when the independence assumption holds.
- What does the evidence probability row mean?
- It is the overall chance of seeing the evidence at all, whether or not the condition is present — the denominator of the theorem, weighting each likelihood by how common its state is. It is worth reporting because it explains the size of the jump: when the evidence is rare overall, a posterior far from the prior is expected, and when the evidence is common it takes a strong likelihood ratio to move anything. In the first example the evidence appears in 5.85% of people, which is why one positive result can move the belief so far.
- When is there no answer at all?
- When the evidence is impossible under every state, which makes the denominator zero and leaves conditioning on it undefined. That happens if both likelihoods are 0%, if the prior is 0% and the false positive rate is 0%, or if the prior is 100% and the detection rate is 0% — in each case the evidence cannot occur, so "given the evidence" is an empty condition. The panel reports an error instead of returning 0% or 50%, because there is no probability to report rather than a probability of zero.
- Does the calculator give the likelihood ratio as well?
- No, and the reason is that the odds form breaks at the ends of the input range. The odds of an event are its probability divided by one minus that probability, so a prior of 100% gives infinite odds, and printing that would break the result panel rather than inform anyone. The shift row does the same job in a form that survives every legal input: it says how far, and in which direction, one piece of evidence moves the belief, which is usually the question behind the request for a likelihood ratio in the first place.
References
- Bayes' Theorem — Stanford Encyclopedia of Philosophy (the theorem itself, its special forms including the odds form, and the subjectivist reading of probability as degree of belief) — Stanford Encyclopedia of Philosophy, Stanford University
- 3.3 Two Basic Rules of Probability — Introductory Statistics 2e (the multiplication rule and conditional probability, which are the two pieces the posterior is assembled from) — OpenStax, Rice University
- 3.5 Tree and Venn Diagrams — Introductory Statistics 2e (the tree-diagram route to the same posterior, which is the count-of-people arithmetic used in the worked examples above) — OpenStax, Rice University