What is Bayes' Theorem?
Bayes' theorem is named after the Reverend Thomas Bayes (1701–1761), an English statistician and philosopher who worked on conditional probability in the eighteenth century. Published posthumously in 1763, Bayes' rule fundamentally changed how we think about probability and inference.
Bayes' rule calculates what can be called the posterior probability of an event — the updated probability of a hypothesis after observing new evidence, taking into account the prior probability of related events. The importance of Bayes' law to statistics can be compared to the significance of the Pythagorean theorem to mathematics.
What is the Bayes' Formula?
In its simplest form, Bayes' theorem calculates the conditional probability P(A|B) — the likelihood of event A occurring provided that B is true:
P(A|B) = [P(B|A) × P(A)] / P(B)
Where:
- P(A) — Prior probability of event A occurring (what you believe before seeing evidence B)
- P(B) — Prior probability of event B occurring (the total probability of the evidence)
- P(A|B) — Posterior probability: probability of A given that B has occurred
- P(B|A) — Likelihood: probability of observing B given that A is true
The equation can also be reversed to find P(B|A):
Bayes' Rule Formula — Tests (Extended Form)
Bayes' theorem is especially powerful when applied to testing scenarios — medical diagnoses, spam filters, drug tests, and more. In the extended form, P(B) is broken down using the law of total probability:
P(B) = P(A) × P(B|A) + P(¬A) × P(B|¬A)
So the full extended formula is:
P(A|B) = [P(B|A) × P(A)] / [P(A) × P(B|A) + P(¬A) × P(B|¬A)]
Where P(¬A) = 1 − P(A) is the probability that event A does not occur, and P(B|¬A) is the probability of observing B when A is false (the false positive rate).
This is the mode our calculator uses by default — you provide P(A), P(B|A), and P(B|¬A), and the calculator computes P(B) and the final posterior P(A|B) for you.
Bayes' Theorem for Dummies — A Step-by-Step Example
Medical Test Example
Suppose a rare disease affects 1% of the population. A test for this disease is:
- 90% sensitive: correctly identifies 90% of sick patients (P(positive | sick) = 90%)
- 5% false positive rate: 5% of healthy people test positive (P(positive | healthy) = 5%)
Question: If a randomly chosen person tests positive, what is the probability they actually have the disease?
| Step | Formula | Calculation | Result |
|---|---|---|---|
| 1. Prior probability | P(sick) | Given | 1% = 0.01 |
| 2. Not sick | P(¬sick) = 1 − P(sick) | 1 − 0.01 | 99% = 0.99 |
| 3. True positive rate | P(+ | sick) | Given | 90% = 0.90 |
| 4. False positive rate | P(+ | ¬sick) | Given | 5% = 0.05 |
| 5. Total positive tests | P(+) = P(sick)×P(+|sick) + P(¬sick)×P(+|¬sick) | 0.01×0.90 + 0.99×0.05 | 5.85% = 0.0585 |
| 6. Posterior probability | P(sick|+) = P(+|sick) × P(sick) / P(+) | 0.90 × 0.01 / 0.0585 | ≈ 15.38% |
Surprising result: Even with a positive test, there is only about a 15.4% chance the person actually has the disease! This is because the disease is so rare that false positives outnumber true positives. This counterintuitive result is why Bayes' theorem is so important in medicine.
Try it in our calculator: Enter P(A) = 1%, P(B|A) = 90%, P(B|¬A) = 5%, and click Calculate.
Possible Test Outcomes Table
For any binary test, there are four possible outcomes:
| Has Disease (A is true) | No Disease (A is false) | |
|---|---|---|
| Test Positive (B) | ✅ True Positive — P(A) × P(B|A) | ❌ False Positive — P(¬A) × P(B|¬A) |
| Test Negative (¬B) | ❌ False Negative — P(A) × P(¬B|A) | ✅ True Negative — P(¬A) × P(¬B|¬A) |
Bayesian Inference — Real Life Applications
Bayes' theorem has countless practical applications across many fields:
🏥 Medicine & Healthcare
- Interpreting diagnostic test results
- Allergy and disease screening accuracy
- Drug trial analysis
- Genetic disease risk assessment
💻 Technology & AI
- Spam email filtering
- Machine learning classifiers (Naive Bayes)
- Natural language processing
- Fraud detection systems
⚖️ Law & Forensics
- DNA evidence interpretation
- Probabilistic reasoning in courts
- Fingerprint and eyewitness reliability
- Crime scene analysis
💰 Finance & Economics
- Credit risk modeling
- Market prediction and Bayesian forecasting
- Insurance risk assessment
- Portfolio optimization
How to Use This Calculator
Extended Mode (Recommended)
Use this mode when you know the false positive rate:
- P(A) — Enter the base rate (prior probability) that A is true, as a percentage (e.g., 1% for a rare disease)
- P(B|A) — Enter the probability of observing B when A is true, as a percentage (e.g., 90% sensitivity)
- P(B|¬A) — Enter the probability of observing B when A is false, as a percentage (e.g., 5% false positive rate)
- Click Calculate — the calculator computes P(B) and P(A|B) automatically
Simple Mode
Use this mode when you already know P(B):
- P(A) — Prior probability of A
- P(B|A) — Likelihood of B given A
- P(B) — Total probability of B (known from data)
- Click Calculate to find P(A|B)
FAQs
What is the difference between prior and posterior probability?
The prior probability P(A) is your initial belief about the probability of event A before observing any evidence. The posterior probability P(A|B) is the updated probability after observing evidence B. Bayes' theorem is the mathematical formula for this update.
What does P(A|B) mean?
P(A|B) is the conditional probability — the probability of event A occurring given that event B has already happened. It is read as "probability of A given B."
Why does a positive test sometimes give a low probability of actually having the disease?
This happens when the base rate P(A) is very small. Even an accurate test will produce many false positives if the condition being tested is very rare. Bayes' theorem correctly accounts for this base rate effect, which is why it is essential for interpreting medical screening tests.
What is Bayesian inference?
Bayesian inference is a statistical framework that applies Bayes' theorem to update probability estimates as new evidence accumulates. Starting from a prior belief, you observe data (evidence) and compute the posterior using Bayes' rule. This posterior then becomes the prior for the next update. This iterative process is the foundation of Bayesian statistics.
What is the base rate fallacy?
The base rate fallacy (or base rate neglect) occurs when people ignore the prior probability P(A) and focus only on the likelihood P(B|A). Bayes' theorem prevents this error by explicitly requiring the base rate as an input.