Bayes' Theorem Calculator
Update probabilities with Bayes' theorem instantly
Bayes' Theorem Calculator
Bayes' theorem calculates the probability that a hypothesis is true, given new evidence. It combines your prior belief (how probable you thought the hypothesis was before seeing the evidence) with the reliability of the test that generated the evidence. The result â the posterior probability â is how confident you should be in the hypothesis now that you have the evidence.
This calculator is used in medical screening, spam detection, legal reasoning, and machine learning to update beliefs based on data.
How to Use This Calculator
- Prior probability â the base rate of the condition or event, before seeing new evidence. Example: 1% of the population has the disease â P(Disease) = 0.01.
- True positive rate (sensitivity) â the probability that the test is positive when the condition is truly present. Example: 95% sensitivity â P(+ | Disease) = 0.95.
- False positive rate â the probability that the test is positive when the condition is absent. Example: 5% false positive rate â P(+ | No Disease) = 0.05.
- Evidence type â whether the observed test result is positive or negative.
Bayes' Theorem Formula
P(H | E) = P(E | H) × P(H) / P(E)
where P(E) = P(E|H) × P(H) + P(E|¬H) × P(¬H).
In plain terms: posterior = (likelihood × prior) / (total probability of evidence).
The Base Rate Fallacy
The most surprising insight from Bayes' theorem is how the prior dramatically affects the posterior. Consider a disease that affects 1% of the population and a test with 95% sensitivity and 5% false positive rate. If the test is positive, most people assume the diagnosis is almost certain. But Bayes' theorem shows P(Disease | +) â 16%. Why? Because when only 1 in 100 people has the disease, most positive tests come from the 99% who are healthy.
This counterintuitive result is called the base rate fallacy, and it is why population-level screening for rare conditions requires careful statistical interpretation.
Real-World Examples
Medical screening: A rare disease has 0.1% prevalence. A test has 99% sensitivity and 1% false positive rate. After a positive test: posterior â 9%. Not 99%.
Spam filtering: 40% of emails are spam a priori. The word "lottery" appears in 80% of spam and 5% of legitimate email. After seeing "lottery": P(spam | lottery) = (0.8 Ã 0.4) / (0.8Ã0.4 + 0.05Ã0.6) â 91.4%.
Drug testing: 2% of athletes use a banned substance. The test has 99% sensitivity and 2% false positive rate. A positive test yields a posterior of about 50% â making false accusations a real concern.