Bayes Theorem Calculator
Updating a Belief With New Evidence
Bayes' theorem is the formal rule for revising a probability once new evidence arrives. It starts with a prior belief about how likely something is, folds in how well the evidence fits that scenario versus the alternative, and produces a posterior probability — the updated belief given what was just observed. It is the mathematical backbone of medical diagnostic testing, spam filtering, and any situation where "positive test result" doesn't automatically mean "condition present."
The Formula
where P(B) = P(B|A) × P(A) + P(B|not A) × P(not A)
Worked Example: A Medical Screening Test
Consider a disease with 1% prevalence in a population (prior P(A) = 0.01), a test with 95% sensitivity (P(B|A) = 0.95), and a 5% false-positive rate (P(B|not A) = 0.05):
| Quantity | Value |
|---|---|
| Prior probability, P(A) | 1% |
| P(B) — overall probability of a positive test | 5.90% |
| Posterior probability, P(A|B) | 16.10% |
Computed directly from the calculator's formula.
Even with a 95%-sensitive test, a positive result only pushes the probability of actually having the (rare) condition up to about 16% — a result that consistently surprises people first encountering it, and the reason low-prevalence screening programs pair a positive result with a confirmatory second test.
Where This Calculation Matters
- Medical diagnostics — interpreting a screening test result correctly requires combining test accuracy with how common the condition is in the population being tested, not just the test's sensitivity and specificity in isolation.
- Spam and fraud filtering — Bayesian classifiers update the probability that a message is spam (or a transaction is fraudulent) based on features observed in the message or transaction.
- Forensic and legal reasoning — evaluating how much a piece of evidence should shift the probability of a hypothesis, avoiding the common "prosecutor's fallacy" of treating P(evidence|innocent) as if it were P(innocent|evidence).
How to Use This Calculator
- Enter the prior probability P(A) — the base rate of the event or condition before any new evidence.
- Enter P(B|A) — the probability of the evidence given the event is true (e.g., test sensitivity).
- Enter P(B|not A) — the probability of the evidence given the event is false (e.g., false-positive rate).
- Select Calculate to get the posterior probability P(A|B).
Related Calculations
For basic probability rules underlying this formula, see the Probability Calculator. For repeated independent trials rather than a single evidence update, use the Probability of Success Calculator.