Bayes Theorem Calculator
Update a prior with test accuracy to get the posterior chance after a positive.
What it does
A positive test result feels decisive until the base rate enters the picture. Bayes theorem corrects that instinct with exact arithmetic: it blends how common a condition is with how the test behaves in sick and healthy people. The output is the posterior, the chance the condition is present given the result in front of you.
The tool above runs the classic screening case. Enter the prior, the sensitivity, and the false positive rate as decimals. It returns the posterior, the total share of positive results, and the likelihood ratio. Defaults describe a 1% condition with a strong test, so the page opens on the worked example and its famous surprise: only 16.67% of positives are true.
That surprise is the base rate fallacy made visible. With 1% prevalence, the 5% false positive slice of the large healthy group (4.95% of everyone) outweighs the true positives (0.99% of everyone) by five to one. Sensitivity matters, but when screening rare conditions the false positive rate and the prior dominate the answer.
Use the example to lock in the method: numerator 0.0099, denominator 0.0594, posterior 16.67%. Then test your own numbers. Raise the prior to model a clinic population, lower the false positive rate to model a confirmatory test, and watch the posterior respond. The likelihood ratio stays fixed for a given test, which makes it handy for comparing tests.
The table below shows how the posterior climbs as the prior rises with the same test. Remember the scope: one binary test, known traits, known base rate. Chained tests, continuous scores, and verification bias call for larger setups, but this page settles the core question fast.
How to use
- Enter the prior as a decimal (1% is 0.01).
- Enter sensitivity as a decimal (99% is 0.99).
- Enter the false positive rate as a decimal (5% is 0.05).
- Read the posterior first, then the total positive rate.
- Compare the likelihood ratio to see test strength at a glance.
- Rerun with a higher prior to model a high risk group.
Formula
- Prior P(A)
- Base rate of the condition before testing, 0 to 1.
- Sensitivity
- True positive share, P(positive|condition).
- False positive rate
- P(positive|no condition), equal to 1 - specificity.
- P(B)
- Total positive share in the population.
- Posterior P(A|B)
- Chance of the condition after a positive result.
P(A) is the prior, P(B|A) is sensitivity, and P(B|not A) is the false positive rate. The denominator P(B) is the total positive share. The form assumes one binary test with known traits and a known base rate; repeat testing and correlated tests need larger models.
Worked example
Example: rare condition, positive test
A condition affects 1% of people. A test has 99% sensitivity and a 5% false positive rate. A person tests positive. What is the chance they carry the condition?
- Numerator = sensitivity x prior = 0.99 x 0.01 = 0.0099.
- Denominator = 0.0099 + 0.05 x 0.99 = 0.0099 + 0.0495 = 0.0594.
- Posterior = 0.0099 / 0.0594 = 0.1667, shown as 16.67 %.
- Positive rate = 0.0594, shown as 5.94 %.
- Likelihood ratio = 0.99 / 0.05 = 19.8 x.
- Even with a good test, most positives are false when the condition is rare.
Reference table
| Prior | Posterior | Total positive |
|---|---|---|
| 0.5% | 9.05 % | 5.47 % |
| 1% | 16.67 % | 5.94 % |
| 2% | 28.78 % | 6.88 % |
| 5% | 51.03 % | 9.70 % |
| 10% | 68.75 % | 14.40 % |
Limits
- One binary test only; no chained or correlated tests.
- Assumes known prior, sensitivity, and false positive rate.
- Ignores indeterminate results and verification bias.
- Point estimates only, with no confidence bands.
Common mistakes
- Entering percents like 5 instead of 0.05.
- Confusing sensitivity with the posterior.
- Forgetting that the prior refers to the tested group, not the globe.
- Ignoring the false positive rate when it drives the answer.
- Reading the total positive share as the posterior.
Try it yourself
Quick checks. Answers sit tucked under each question.
Prior 0.02, sensitivity 0.95, false positive 0.10?
Posterior is 16.24 %. Positives are 11.70 %. Ratio is 9.5 x.
Prior 0.1, sensitivity 0.9, false positive 0.2?
Posterior is 33.33 %. Positives are 27.00 %. Ratio is 4.5 x.
Prior 0.04, sensitivity 0.8, false positive 0.1? Work it by hand.
Numerator 0.032, denominator 0.032 + 0.096 = 0.128, posterior 25.00 %.
Questions
What is Bayes theorem?
A rule that turns a prior plus test traits into a posterior: P(A|B) = P(B|A)P(A) / P(B). It tells how to revise beliefs after new evidence.
Sensitivity versus specificity?
Sensitivity is P(positive|sick), the true positive share. Specificity is P(negative|healthy). False positive rate = 1 - specificity.
Why is the posterior only 16.67 % here?
Because the healthy group is huge. At 1% prevalence, 5% of the 99% healthy (4.95%) dwarfs the 0.99% true positives, so most positives are false.
Can the false positive rate be 0?
Yes. Enter 0 for false positives only when specificity is truly perfect; the tool then reports an infinite ratio and a posterior of 100% for positive sensitivity.
Percent or decimal inputs?
Use decimals from 0 to 1 here: 1% is 0.01, 99% is 0.99. Mixing 1 with 0.01 in one row is the most common slip.
What happens when the prior rises?
It rises fast. Double the prior to 2% with the same test and the posterior climbs to about 28%. Base rates drive screening results.