Bayes' Theorem Calculator

Reviewed by CalcMulti Editorial Team·Last updated: ·Statistics Hub

Bayes' theorem calculates the probability of a hypothesis being true given new evidence. It is the foundation of Bayesian statistics, medical test interpretation, spam filters, and machine learning classifiers.

Enter the prior probability P(A), the true positive rate P(B|A), and the false positive rate P(B|¬A) to compute the posterior probability P(A|B) — the probability the hypothesis is true after observing the evidence.

Formula

P(A|B) = P(B|A) × P(A) / [P(B|A)×P(A) + P(B|¬A)×P(¬A)]

P(A)
prior probability — P(hypothesis is true) before seeing evidence
P(B|A)
likelihood — P(evidence | hypothesis true); sensitivity in medical tests
P(B|¬A)
false positive rate — P(evidence | hypothesis false); 1 − specificity
P(A|B)
posterior probability — P(hypothesis true | evidence observed)

Quick Presets

Enter Probabilities

%e.g. 1% = disease affects 1 in 100 people
%P(positive test | disease present)
%P(positive test | disease absent)

Bayes' Theorem Formula

P(A|B) = P(B|A) × P(A) / P(B)

P(B) = P(B|A)×P(A) + P(B|¬A)×(1−P(A))

TermSymbolMedical test meaning
Prior probabilityP(A)Disease prevalence in the population
Sensitivity (TPR)P(B|A)P(positive test | disease present)
False positive rateP(B|¬A)P(positive test | no disease) = 1 − specificity
Marginal probabilityP(B)Overall P(positive test) across everyone tested
Posterior probabilityP(A|B)P(disease | positive test) — the answer we want

Worked Example: Rare Disease Screening

A disease affects 1% of the population. The screening test has 95% sensitivity and a 5% false positive rate. What is the probability that a patient who tests positive actually has the disease?

Step 1 — True positivesP(B|A) × P(A) = 0.95 × 0.01 = 0.0095
Step 2 — False positivesP(B|¬A) × P(¬A) = 0.05 × 0.99 = 0.0495
Step 3 — Total P(B)0.0095 + 0.0495 = 0.0590
Step 4 — PosteriorP(A|B) = 0.0095 / 0.0590 ≈ 16.1%

Key insight (base rate neglect): Even with a 95% accurate test, only ~16% of positive results indicate true disease when prevalence is 1%. Most positive tests (84%) are false positives. This surprises clinicians and is why confirmatory testing matters for rare conditions.

When to Use Bayes' Theorem

Medical diagnosis

Interpret test results given disease prevalence. Critical when base rates are low.

Spam filtering

Classify emails using P(spam | word) from known spam frequencies.

A/B test interpretation

Update beliefs about variant performance as data accumulates.

Legal & forensics

DNA match probability depends heavily on the prior probability of guilt.

Machine learning

Naïve Bayes classifies text by combining per-feature likelihoods with priors.

Risk & anomaly detection

Update failure probability given diagnostic sensor signals.

Interpreting Positive Likelihood Ratios

LR+ = Sensitivity / FPR. Measures how much a positive result shifts the odds of the condition.

LR+InterpretationClinical utility
> 10Large, clinically important shiftStrong — rules in the condition
5–10Moderate shiftGood evidence
2–5Small to moderate shiftWeak evidence — use with other findings
1–2Minimal shiftLittle diagnostic value
= 1No shiftPositive result is meaningless

Disclaimer

This calculator applies Bayes' theorem for discrete binary events. For continuous distributions, consult a Bayesian statistics reference.

Frequently Asked Questions