Bayes' Theorem Calculator

Find the true probability of a condition given a positive test result — often far lower than you'd guess.

How this is calculated

Bayes' theorem combines your prior probability with the test's sensitivity and specificity to find the posterior probability — P(condition | positive test). It works by comparing true positives against the sum of true and false positives: P(condition|positive) = P(positive|condition) × P(condition) / P(positive). The confusion matrix shows exactly where those numbers come from, applied to a hypothetical population of 10,000 people.

Consider a medical test with 99% sensitivity and 99% specificity for a disease with 1% prevalence. Out of 10,000 people, 100 actually have the disease, of whom 99 test positive (true positives). Of the 9,900 healthy people, 1% — 99 people — also test positive (false positives). So out of 198 total positive results, only 99 are true positives: a posterior probability of just 50%, despite the test being "99% accurate" on paper. This is the base rate fallacy in action — a test can be highly accurate and still produce a coin-flip result when the condition it's testing for is rare. For another probability result that defies most people's intuition, see the Birthday Paradox calculator, and for calculating how large a sample needs to be before a probability estimate becomes statistically reliable, see the Sample Size calculator.

Frequently asked questions

Why is the posterior probability so much lower than the test's accuracy?
When a condition is rare, most positive results come from the much larger pool of healthy people who got a false positive — even a small false-positive rate, applied to a huge healthy population, can outnumber the true positives from a tiny affected population. This is the base rate fallacy, and it's exactly what Bayes' theorem corrects for.
What is the difference between sensitivity and specificity?
Sensitivity is how often the test correctly identifies people who DO have the condition (true positive rate). Specificity is how often it correctly clears people who DON'T have it (true negative rate). A test can be excellent on both and still produce a low posterior probability if the underlying condition is rare.
What do PPV and NPV mean?
Positive Predictive Value (PPV) is the same as the posterior probability — the chance you actually have the condition given a positive result. Negative Predictive Value (NPV) is the chance you're actually condition-free given a negative result — for rare conditions, NPV is typically very high.
Can I use this in my own app?
Yes — every calculator on Stupidly Clever has a matching REST API and MCP tool that runs the same underlying logic.
What is Bayes' theorem?
Bayes' theorem is a formula for updating a probability estimate as new evidence arrives. It combines a prior probability (what you believed before the evidence) with how well the evidence discriminates between outcomes, producing a posterior probability (what you should believe after the evidence).
What is the difference between prior and posterior probability?
The prior is your probability estimate before seeing new evidence — for a medical test, this is typically the disease's prevalence in the population. The posterior is the updated probability after incorporating the evidence — for a medical test, this is the chance you actually have the condition given a positive result.
What is a likelihood ratio?
A likelihood ratio compares how much more likely a piece of evidence is under one hypothesis versus another — for a positive test result, it's the true positive rate divided by the false positive rate. A higher likelihood ratio means the evidence shifts your probability estimate more strongly.
What is a false positive in the context of Bayes' theorem?
A false positive is a positive test result for someone who does not actually have the condition. Even a test with a low false-positive rate can generate more false positives than true positives in absolute terms when the condition is rare, which is exactly the effect Bayes' theorem quantifies — see the worked example above.

Related calculators