Bayes' Theorem Calculator
Free Bayes' theorem calculator with step-by-step solutions. Calculate posterior probabilities for medical tests and diagnostics.
Initial probability of A before evidence
Probability of B given A is true
Overall probability of observing B
Bayes' Theorem
P(A|B) = P(B|A) × P(A) / P(B)
P(A):
Prior probability (before evidence)
P(A|B):
Posterior probability (after evidence)
P(B|A):
Likelihood (evidence given hypothesis)
P(B):
Marginal likelihood (total probability)
How to Use the Bayes’ Theorem Calculator
This calculator helps you apply Bayes’ theorem to update probabilities based on new evidence. It’s essential for medical diagnosis, spam detection, and decision-making under uncertainty.
What is Bayes’ Theorem?
Bayes’ theorem calculates the probability of a hypothesis given observed evidence:
P(A|B) = P(B|A) × P(A) / P(B)
Where:
- P(A) = Prior probability (your initial belief)
- P(B|A) = Likelihood (probability of evidence given hypothesis is true)
- P(B) = Marginal probability (total probability of observing the evidence)
- P(A|B) = Posterior probability (updated belief after seeing evidence)
Calculation Modes
Simple Mode
Use when you already know P(B), the total probability of the evidence.
Full Mode
Calculates P(B) automatically using the Law of Total Probability:
P(B) = P(B|A) × P(A) + P(B|A’) × P(A’)
This requires:
- P(B|A) - Sensitivity (true positive rate)
- P(B|A’) - False positive rate
Common Applications
Medical Testing
- P(A): Disease prevalence (e.g., 1% of population)
- P(B|A): Test sensitivity (e.g., 95% for true positives)
- P(B|A’): 1 - Test specificity (e.g., 10% false positive rate)
Example: If a disease affects 1% of people, and a test has 95% sensitivity and 90% specificity, what’s the probability someone has the disease given a positive test?
Spam Filtering
- P(A): Prior probability an email is spam (e.g., 30%)
- P(B|A): Probability the word appears in spam (e.g., 80%)
- P(B|A’): Probability the word appears in legitimate email (e.g., 10%)
Example: Medical Test
Scenario: A disease affects 1 in 100 people. A test for this disease:
- Correctly identifies 95% of sick people (sensitivity)
- Incorrectly flags 10% of healthy people (false positive rate)
If you test positive, what’s the probability you actually have the disease?
Input:
- P(A) = 0.01 (disease prevalence)
- P(B|A) = 0.95 (sensitivity)
- P(B|A’) = 0.10 (false positive rate)
Result: P(A|B) ≈ 0.0876 or about 8.8%
This surprisingly low result (despite a “95% accurate” test) demonstrates the base rate fallacy - when a condition is rare, even accurate tests can produce many false positives.
The Base Rate Fallacy
One of the most important insights from Bayes’ theorem is that test accuracy alone doesn’t determine how much we should trust a positive result. The base rate (prior probability) matters enormously.
| Disease Prevalence | P(Disease | Positive Test) |
|---|---|
| 50% (common) | 90.5% |
| 10% | 51.4% |
| 1% (rare) | 8.8% |
| 0.1% (very rare) | 0.9% |
All calculations assume 95% sensitivity, 90% specificity
Key Concepts
Prior Probability
Your initial estimate before seeing evidence. In medical contexts, this is often the disease prevalence in the relevant population.
Likelihood
How probable is the evidence if the hypothesis is true? For medical tests, this is sensitivity.
Posterior Probability
Your updated belief after incorporating the evidence. This becomes the new prior for subsequent updates.
Likelihood Ratio
The ratio P(B|A) / P(B|A’) tells you how much the evidence favors the hypothesis:
- LR > 1: Evidence supports the hypothesis
- LR < 1: Evidence argues against the hypothesis
- LR = 1: Evidence is uninformative
Related Resources
- Conditional Probability - Foundation for Bayes’ theorem
- Probability Calculator - Basic probability operations
- Law of Total Probability - How P(B) is calculated
Want to learn the theory?
Our lessons explain the statistical concepts behind this calculator with clear examples.
Browse Lessons →