Bayes' Theorem Calculator
Calculate posterior probability using Bayes' theorem. Enter prior, likelihood, and false positive rate to compute P(A|B) with visual results.
Probability of hypothesis before evidence
True positive rate (sensitivity)
1 โ Specificity
About
Misapplying conditional probability costs lives and money. A medical test with 99% accuracy applied to a disease with 0.1% prevalence yields a positive predictive value below 10%. Most professionals get this wrong. Bayes' theorem corrects the intuition failure by computing the posterior probability P(A|B) from three inputs: the prior P(A), the true positive rate P(B|A), and the false positive rate P(B|ยฌA). This calculator implements both the standard and odds forms, handles edge cases where P(B) = 0, and displays the full decomposition via the Law of Total Probability.
The tool assumes binary hypothesis space (A vs ยฌA). For multi-class problems, apply sequential updating. Note that the model treats all probabilities as exact point estimates. It does not account for uncertainty in the parameters themselves. For robust inference under parameter uncertainty, use a full Bayesian framework with conjugate priors.
Formulas
The standard form of Bayes' theorem for a binary hypothesis:
The denominator P(B) is expanded using the Law of Total Probability:
The odds form provides an alternative representation using the likelihood ratio LR:
Where: P(A) = prior probability of hypothesis A being true. P(B|A) = likelihood (sensitivity, true positive rate). P(B|ยฌA) = false positive rate (1 โ specificity). P(A|B) = posterior probability after observing evidence B. LR = likelihood ratio, quantifying the diagnostic strength of the evidence.
Reference Data
| Domain | Prior P(A) | Sensitivity P(B|A) | False Positive P(B|ยฌA) | Posterior P(A|B) | Notes |
|---|---|---|---|---|---|
| Breast Cancer Screening (Mammography) | 0.008 | 0.90 | 0.07 | 0.094 | ~9.4% PPV despite high sensitivity |
| HIV ELISA Test | 0.003 | 0.998 | 0.0001 | 0.968 | Very low false positive rate drives high PPV |
| COVID-19 Rapid Antigen (High Prevalence) | 0.15 | 0.72 | 0.02 | 0.864 | Prevalence 15% scenario |
| COVID-19 Rapid Antigen (Low Prevalence) | 0.01 | 0.72 | 0.02 | 0.267 | Same test, different context |
| Email Spam Filter | 0.40 | 0.95 | 0.05 | 0.927 | Assumes 40% spam base rate |
| Airport Security (Contraband) | 0.0001 | 0.95 | 0.10 | 0.00095 | Base rate fallacy in security screening |
| Criminal Court (DNA Match) | 0.001 | 0.9999 | 0.0001 | 0.909 | Prosecutor's fallacy if prior ignored |
| Drug Test (Workplace) | 0.05 | 0.99 | 0.01 | 0.839 | 5% user prevalence assumed |
| Weather Forecast (Rain) | 0.30 | 0.80 | 0.10 | 0.774 | Climatological prior for temperate region |
| Fire Alarm (Real Fire) | 0.0005 | 0.99 | 0.02 | 0.024 | Most alarms are false |
| Manufacturing Defect Detection | 0.02 | 0.95 | 0.03 | 0.393 | Quality control at 2% defect rate |
| Rare Disease Genetic Test | 0.0001 | 0.999 | 0.005 | 0.020 | Illustrates danger of screening rare conditions |
| Financial Fraud Detection | 0.01 | 0.85 | 0.05 | 0.147 | 1% transaction fraud rate |
| Self-Driving Car Object Detection | 0.001 | 0.999 | 0.001 | 0.500 | Equal likelihood ratio at this prior |
| Pregnancy Test | 0.30 | 0.99 | 0.01 | 0.977 | High prior among test-takers |