Bayes' Theorem Calculator

Apply Bayes' theorem to update probabilities with new evidence — compute posterior probability, likelihood ratios, and confusion matrices for medical tests.

Base rate / prevalence
P(positive | disease)
P(negative | no disease)
Posterior P(A|B)
0.087558
8.76% — updated probability after evidence
P(¬A | B)
0.912442
Probability hypothesis is false given positive evidence
P(B)
0.108500
Total probability of observing the evidence
Positive LR
9.500
Sensitivity / (1 − Specificity)
Negative LR
0.0556
(1 − Sensitivity) / Specificity
NPV
99.94%
Negative predictive value
Prior Odds
0.0101
P(A) / P(¬A)
Posterior Odds
0.0960
Prior odds × LR+

Confusion Matrix (per 10,000 individuals)

Disease+Disease−Total
Test+95.0 (TP)990.0 (FP)1,085.0
Test−5.0 (FN)8,910.0 (TN)8,915.0
Total100.09,900.010,000

Posterior vs. Prior (Sensitivity Analysis)

Prior P(A)Posterior P(A|B)ChangeVisual
0.1%0.94%0.84pp
0.5%4.56%4.06pp
1.0%8.76%7.76pp
2.0%16.24%14.24pp
5.0%33.33%28.33pp
10.0%51.35%41.35pp
20.0%70.37%50.37pp
50.0%90.48%40.48pp
Planning notes, formulas, and examples

About the Bayes' Theorem Calculator

Bayes' theorem updates a hypothesis probability after new evidence arrives. Given a prior probability, the likelihood of the evidence if the hypothesis is true, and the likelihood of the evidence if it is false, the calculator computes the posterior probability.

This page supports both a medical-test mode and a general conditional-probability mode. In medical mode it uses sensitivity and specificity; in general mode it uses the raw conditional probabilities directly. The output includes posterior probability, likelihood ratios, and a confusion matrix scaled to 10,000 people so the numbers stay concrete.

That makes the page useful anywhere a base rate and an observed result need to be combined into one updated probability.

When This Page Helps

Bayesian updating is the cleanest way to combine prior belief with new evidence, but it is easy to misread if you focus on the test result alone. The base rate often matters more than intuition suggests.

Putting the posterior, likelihood ratios, and confusion matrix together makes it easier to see why a positive result can still leave substantial uncertainty.

How to Use the Inputs

  1. Choose medical test mode (sensitivity/specificity) or general mode (raw conditional probabilities).
  2. Enter the prior probability P(A) — the base rate or prevalence before observing evidence.
  3. In medical mode, enter sensitivity (true positive rate) and specificity (true negative rate).
  4. In general mode, enter P(B|A) and P(B|¬A) directly.
  5. Read the posterior probability P(A|B) from the output — this is the updated probability after positive evidence.
  6. Review the confusion matrix to understand true/false positives in a population of 10,000.
  7. Check the sensitivity analysis table to see how different base rates change the result.
Formula used
P(A|B) = [P(B|A) × P(A)] / [P(B|A) × P(A) + P(B|¬A) × P(¬A)]. Positive Likelihood Ratio = Sensitivity / (1 − Specificity). Posterior Odds = Prior Odds × LR+.

Example Calculation

Result: P(Disease | Positive Test) ≈ 0.0876 (8.76%)

With 1% prevalence, 95% sensitivity, and 90% specificity: P(+) = 0.95×0.01 + 0.10×0.99 = 0.1085. Posterior = (0.95×0.01)/0.1085 ≈ 8.76%. Even with a positive test, there's only about a 9% chance of actually having the disease.

Tips & Best Practices

  • A low base rate dramatically reduces the posterior even with highly accurate tests — this is the base rate fallacy.
  • Use the sensitivity analysis table to see the "tipping point" where a positive test becomes more likely true than false.
  • Positive likelihood ratio > 10 indicates a strong test; < 2 is weak.
  • NPV (negative predictive value) tells you how reassured you should be by a negative test result.
  • For serial testing (two positive tests in a row), use the posterior from the first test as the prior for the second.
  • The confusion matrix makes the abstract math concrete — seeing actual counts per 10,000 people is much more intuitive.

The Base Rate Fallacy

The most famous illustration of Bayes' theorem is the medical screening paradox. A disease affecting 1% of the population is screened with a 95% sensitive, 90% specific test. Most people guess a positive result means ~95% chance of disease. The actual answer is under 9%. This counterintuitive result occurs because false positives from 99% of healthy individuals vastly outnumber true positives from 1% of sick individuals.

Bayesian vs. Frequentist Thinking

Frequentist statistics evaluates the probability of data given a fixed hypothesis. Bayesian statistics flips this — it evaluates the probability of a hypothesis given observed data. Bayes' theorem is the mathematical bridge between these perspectives.

Serial Testing and Prior Updating

In clinical practice, a second test isn't independent — the patient's prior has been updated by the first test. Use the posterior from the first positive test as the prior for the second test. Two consecutive positives with independent tests dramatically increase the posterior probability.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • It's a formula that tells you how to update your belief after seeing new evidence. If you think there's a 1% chance of something, and you get a positive signal, Bayes' theorem tells you the new (higher) probability.