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
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))
| Term | Symbol | Medical test meaning |
|---|---|---|
| Prior probability | P(A) | Disease prevalence in the population |
| Sensitivity (TPR) | P(B|A) | P(positive test | disease present) |
| False positive rate | P(B|¬A) | P(positive test | no disease) = 1 − specificity |
| Marginal probability | P(B) | Overall P(positive test) across everyone tested |
| Posterior probability | P(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?
P(B|A) × P(A) = 0.95 × 0.01 = 0.0095P(B|¬A) × P(¬A) = 0.05 × 0.99 = 0.04950.0095 + 0.0495 = 0.0590P(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+ | Interpretation | Clinical utility |
|---|---|---|
| > 10 | Large, clinically important shift | Strong — rules in the condition |
| 5–10 | Moderate shift | Good evidence |
| 2–5 | Small to moderate shift | Weak evidence — use with other findings |
| 1–2 | Minimal shift | Little diagnostic value |
| = 1 | No shift | Positive result is meaningless |
Related Calculators
Frequentist approach to evidence
Probability Rules ExplainedConditional probability fundamentals
Normal Distribution CalculatorBayesian priors often normal
Hypothesis Testing BasicsFrequentist hypothesis testing
Null Hypothesis ExplainedH₀ and H₁ explained
Statistics HubAll statistics calculators
Disclaimer
This calculator applies Bayes' theorem for discrete binary events. For continuous distributions, consult a Bayesian statistics reference.