Bayes' Theorem: formula
The result depends on accurate inputs, and prevalence is often uncertain. Tests are not independent when repeated on the same person. Real decisions use clinical context, symptoms and follow-up tests, not one probability.
The same math applies to spam filters, security alerts and legal evidence, where the base rate is often ignored.
Bayes' Theorem: worked example
| Prevalence (prior chance) | 1.0% |
|---|---|
| Sensitivity | 90.0% |
| False positive rate | 5.0% |
| Chance of the condition after a positive test | 15.4% |
| Chance of a positive test overall | 5.9% |
| Chance of the condition after a negative test | 0.106% |
Prevalence is the proportion with the condition before testing. Sensitivity is the probability of a positive result with the condition; the false-positive rate is the probability of a positive result without it. Take these from the test's documentation or studies.
Specificity equals one minus the false positive rate. Use the prevalence in the group being tested, not the general population, since it changes the result greatly.
Bayes' Theorem: changing Prevalence (prior chance)
| Prevalence (prior chance) | Chance of the condition after a positive test | Chance of a positive test overall | Chance of the condition after a negative test |
|---|---|---|---|
| 0.500% | 8.3% | 5.4% | 0.053% |
| 0.750% | 12.0% | 5.6% | 0.079% |
| 1.0% (example) | 15.4% | 5.9% | 0.106% |
| 1.3% | 18.6% | 6.1% | 0.133% |
| 1.5% | 21.5% | 6.3% | 0.160% |
Bayes' Theorem: compare input ranges
| Input | Tested from | To | Chance of the condition after a positive test: low input | Chance of the condition after a positive test: high input | Swing |
|---|---|---|---|---|---|
| Prevalence (prior chance) | 0.750% | 1.3% | 12.0% | 18.6% | 6.6% (43%) |
| False positive rate | 4.0% | 6.0% | 18.5% | 13.2% | 5.4% (35%) |
| Sensitivity | 88.0% | 92.0% | 15.1% | 15.7% | 0.579% (3.8%) |
Bayes' Theorem: individual input comparisons
| Input | Value | Chance of the condition after a positive test | Chance of a positive test overall | Chance of the condition after a negative test |
|---|---|---|---|---|
| Prevalence (prior chance) | 0.500% | 8.3% | 5.4% | 0.053% |
| 0.750% | 12.0% | 5.6% | 0.079% | |
| 1.0% | 15.4% | 5.9% | 0.106% | |
| 1.3% | 18.6% | 6.1% | 0.133% | |
| 1.5% | 21.5% | 6.3% | 0.160% | |
| Sensitivity | 86.0% | 14.8% | 5.8% | 0.149% |
| 88.0% | 15.1% | 5.8% | 0.127% | |
| 90.0% | 15.4% | 5.9% | 0.106% | |
| 92.0% | 15.7% | 5.9% | 0.085% | |
| 94.0% | 16.0% | 5.9% | 0.064% | |
| False positive rate | 3.0% | 23.3% | 3.9% | 0.104% |
| 4.0% | 18.5% | 4.9% | 0.105% | |
| 5.0% | 15.4% | 5.9% | 0.106% | |
| 6.0% | 13.2% | 6.8% | 0.107% | |
| 7.0% | 11.5% | 7.8% | 0.108% |
Bayes' Theorem: combined input changes
| Prevalence (prior chance) / Sensitivity | 86.0% | 90.0% | 94.0% |
|---|---|---|---|
| 0.500% | 8.0% | 8.3% | 8.6% |
| 0.750% | 11.5% | 12.0% | 12.4% |
| 1.0% | 14.8% | 15.4% | 16.0% |
| 1.3% | 17.9% | 18.6% | 19.2% |
| 1.5% | 20.8% | 21.5% | 22.3% |
Bayes' Theorem: which assumptions move the result?
Bayes' Theorem: values and definitions
| Quantity and definition | Value used |
|---|---|
| Prevalence (prior chance) — How common the condition is before any test. | 1.0% |
| Sensitivity — The chance the test is positive when the condition is present. | 90.0% |
| False positive rate — The chance the test is positive when the condition is absent. | 5.0% |
| Chance of the condition after a positive test | 15.4% |
| Chance of a positive test overall | 5.9% |
| Chance of the condition after a negative test | 0.106% |
Bayes' Theorem: half and double Prevalence (prior chance)
| Prevalence (prior chance) | Chance of the condition after a positive test |
|---|---|
| 0.500% | 8.3% |
| 1.0% | 15.4% |
| 2.0% | 26.9% |
Common error: Reading sensitivity as the chance of having the condition after a positive test. Those are different numbers, and mixing them up is one of the most common errors in medical testing.
Statistics & Probability calculators: Mean & Median Calculator, Standard Deviation Calculator, Range & Midrange Calculator, Permutation & Combination Calculator, Simple Probability Calculator, Z-Score Calculator.
For a hypothetical group of 10,000 with 1% prevalence, 100 have the condition and 9,900 do not. At 90% sensitivity, 90 affected people test positive. A 5% false-positive rate adds 495 positive results from the unaffected group.
Only 90 of the 585 positive results are true positives: about 15.38%. The other 9,415 results are negative, including 10 affected people, so the chance after a negative result is about 0.106%. These counts follow from the entered assumptions; they are not observations from a clinical study.
Use the prevalence for the group being tested. A person with symptoms starts from a much higher prior than one tested at random, and the same test means more for them.
See the basic probability and binomial probability calculators, and the expected value page for decisions under uncertainty. The z-score, p-value and confidence interval calculators cover statistical testing. The permutation and combination page counts outcomes, which helps when you need to list every way an event can happen before applying the theorem.
Why is a positive test often a false alarm for rare conditions?
Because the healthy group is much larger, even a small false positive rate produces more false positives than there are true positives.
What is the base rate?
The prevalence of the condition in the population being tested, which strongly affects what a positive result means.
What are sensitivity and specificity?
Sensitivity is the share of people with the condition who test positive, and specificity is the share without it who test negative.