Bayes theorem calculator
Enter the prior P(A), the likelihood P(B|A) and the false positive rate P(B|¬A) to get the posterior P(A|B), the total probability and the likelihood ratio — explained with a natural frequency table per 1000 people.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
16.6667%5.9400%19.80.01010.295.0000%1.0000%1.0525%In plain counts: out of 1000 people about 10 really have the condition and 60 test positive. Of those 60 positives only 10 are real cases — the other 50 are false alarms.
109901050094060940What this tool does
- Read a screening report properly: with a 1% prevalence, 99% sensitivity and a 5% false positive rate, a positive result still means only about a 16.7% chance of disease — the frequency table shows why in one glance.
- Sanity-check a binary classifier such as a spam filter or fraud detector: turn its historical accuracy into a posterior probability before trusting an alert.
- Understand the base rate fallacy: the smaller the prior, the lower the posterior for the same test result — change the prior and watch it move.
- Do probability homework: the total probability, the Bayes update and the “prior odds × likelihood ratio = posterior odds” identity are all laid out side by side.
Example
Input
Prior P(A) = 1%, sensitivity P(B|A) = 99%, false positive rate P(B|¬A) = 5%, population 1000
Output
Total probability P(B) = 5.9400%, posterior P(A|B) = 16.6667%, likelihood ratio = 19.8, prior odds = 0.0101, posterior odds = 0.2; out of 1000 people about 10 are sick and 60 test positive — 10 true positives and 50 false positives
The false positive rate is five times smaller than the sensitivity, yet because there are so many healthy people the false alarms outnumber the real positives five to one.
Frequently asked questions
Why does a 99% sensitive test leave only a 16.7% chance of disease after a positive result?
Because the prevalence is only 1%. Out of 1000 people just 10 are sick and the test catches about 10 of them, while the 990 healthy people produce roughly 50 false alarms at a 5% false positive rate. With about 60 positives in total, only 10/60 ≈ 16.7% are real cases. The prior (base rate) dominates.
What does “prior odds × likelihood ratio = posterior odds” mean?
It is the odds form of Bayes’ theorem and the handiest version in practice: prior odds = P(A)/P(¬A) = 0.01/0.99 ≈ 0.0101 and the likelihood ratio = 0.99/0.05 = 19.8, so the posterior odds are ≈ 0.2, giving P(A|B) = 0.2/1.2 = 1/6 ≈ 16.7%. Evidence simply multiplies the prior odds.
Why are the frequency counts whole numbers while the probabilities are decimals?
The frequency table is meant to be read by people: the probabilities are multiplied by the population and rounded to whole people, so you can say “about 10 out of 1000”. Rounding shifts each count by at most ±1, which is why the predictive value in the table can differ slightly from the posterior above — trust the probability.
Why is the negative predictive value so high?
The negative predictive value is the chance that a person who tests negative really is healthy. When the prevalence is low, almost everyone who tests negative was healthy to begin with, so this number sits close to 1. That does not make the test accurate — it only means negative results rarely miss a case.
What happens if I set the false positive rate to 0?
The likelihood ratio becomes infinite, which means a positive result guarantees a real case and the posterior jumps to 100%. That is the ideal-test extreme; real tests never have a zero false positive rate, so enter your actual figures.
Keywords:bayes theoremposterior probabilitypriorlikelihoodfalse positivelikelihood ratiobase rate贝叶斯定理后验概率先验概率假阳性似然比全概率