Statistics & Probability

Bayes’ Theorem Calculator

Posterior probabilities from priors and likelihoods, and PPV and NPV of a test from sensitivity and specificity.

Tool no.
ECT-P11
Rev
1.0
Updated
Oct 2026
Method
Bayes’ theorem and total probability
Examples

Given

name, prior, P(evidence | hypothesis). Percents and fractions are fine.

Answers

P(A | positive) =—
Runs in your browser. Nothing you enter is uploaded.P(A|B) = P(B|A)P(A)/P(B)
How to use this calculator

For a test, enter the prior probability (prevalence), the sensitivity and the specificity. For anything else, list each hypothesis with its prior and the probability of the evidence if it were true; the hypotheses should be mutually exclusive and cover every case.

Formulas

Bayes’ theoremP(A|B) = P(B|A)P(A)/P(B)
Total probabilityP(B) = Σ P(B|Ai)P(Ai)
PPVP(A|+) = sens·p/[sens·p + (1 − spec)(1 − p)]

Worked example

A test with 95% sensitivity and 90% specificity for a condition with 1% prevalence

  1. P(+) = 0.95 × 0.01 + 0.10 × 0.99 = 0.1085.
  2. P(A | +) = 0.0095/0.1085 = 8.76%.
  3. In 10 000 people: 95 true positives and 990 false positives, so most positives are false.
  4. A second independent positive raises it to 47.7%.

Frequently asked questions

Why is the posterior so low when the test is accurate?

Because the condition is rare. False positives come from the 99% without it, so even a 10% false-positive rate swamps the true positives. This is the base-rate fallacy.

What are sensitivity and specificity?

Sensitivity is the probability of a positive result when the condition is present; specificity is the probability of a negative result when it is absent.

Do the priors have to add to 1?

They should, because the hypotheses must cover every possibility. If they don’t, the calculator scales them and warns you.