Bayes' Theorem Calculator

Find the posterior probability P(A|B).

How it is calculated

The tool computes the posterior probability that the condition is really present given a positive result:

P(A|B) = (sens × prior) / (sens × prior + fpr × (1 − prior))

Here prior is the base rate before testing, sens is the sensitivity (chance of a positive when the condition is present) and fpr is the false-positive rate (chance of a positive when it is absent). All three are entered as fractions between 0 and 1, not percentages. The denominator is the total chance of a positive result from both groups. The answer is shown as a percentage with two decimals. A value outside 0 to 1, or a zero denominator, gives no result.

Worked example

Take a condition affecting 1 in 100 people (prior = 0.01), a test with sensitivity 0.9 and a false-positive rate of 0.05.

  1. True positives: 0.9 × 0.01 = 0.009
  2. False positives: 0.05 × 0.99 = 0.0495
  3. Total positives: 0.009 + 0.0495 = 0.0585
  4. Posterior: 0.009 / 0.0585 ≈ 15.38%

Despite a good-looking test, a positive result means only about a 15% chance, because the condition is rare.

Try this example →

Common mistakes

  • Typing percentages such as 1 or 90 instead of fractions such as 0.01 or 0.9: values above 1 are rejected and a prior of 1 means certainty.
  • Confusing sensitivity with the posterior: a 90% sensitive test does not mean a positive result is 90% likely to be right.
  • Entering the specificity where the false-positive rate belongs: the false-positive rate is 1 minus specificity.
  • Ignoring the prior (base rate): for rare conditions most positives are false positives even with an accurate test.

About this calculator

This calculator applies Bayes' theorem, P(A|B) = P(B|A)·P(A) / P(B), to update a prior probability P(A) into a posterior probability P(A|B) once new evidence B is observed — using a test's sensitivity (true positive rate) and false-positive rate to work out how likely something is to actually be true given a positive result. It's the mathematical backbone of Bayesian inference: reasoning that formally combines what you believed beforehand with what new data tells you.

Doctors and epidemiologists use it to interpret medical test results correctly — a positive result for a rare disease can still mean a low actual probability of having it if the false-positive rate is high relative to the disease's prevalence. Statisticians, data scientists building spam filters and machine-learning classifiers, and forensic analysts weighing evidence all use this same reasoning; students learning probability use this calculator to build intuition for why “positive” doesn't always mean “likely.”

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    You can chain evidence: enter the posterior from a first positive as the new prior, written as a fraction, to see what a second positive would imply. In the 1-in-100 example, a prior of 0.1538 gives about 76.6%. That holds only if the second test's errors are independent of the first, which fails when the same method or sample repeats the same mistake. Which situation are you modelling: a screening test, a spam filter, a quality check? Post the three numbers you used.

Popular calculators

All Calculators