🧮
🧮 Math & statistics

Bayes’ Theorem Calculator (test accuracy)

Results update as you type.

Your numbers

Understanding the Bayes' theorem calculator — concept and principle

Bayes' theorem updates a probability when new evidence arrives. The classic use is a diagnostic or screening test: given how common a condition is (the prior), how often the test detects it (sensitivity) and how often it falsely alarms (false positive rate), what is the chance that a person with a positive result really has the condition? The same logic drives spam filters and fraud alerts.

Bayes theorem with natural frequenciesOf 10,000 people, 100 have the condition and 90 of them test positive; 495 of the 9,900 healthy also test positive. 90 ÷ 585 = 15.38%.A positive test, 10,000 people10,000 people1% have it100 people99% do not9,900 people9090% test +10missed4955% false +9,405test −All 585 positives:90495 false alarms90 ÷ 585 = 15.38%chance of really being ill if positive
With a 1% prior, false alarms outnumber true positives more than five to one.

How it is calculated

Let A be "has the condition" and B be "test is positive". Enter the three rates as percentages.

The principle

Bayes' theorem follows from writing the same overlap two ways: P(A ∩ B) = P(B|A)·P(A) = P(A|B)·P(B). Dividing by P(B) turns "how likely is the evidence if A is true" into "how likely is A given the evidence". The key insight is that positives come from two groups: true positives among the few who have the condition and false positives among the many who do not. When the condition is rare, the second group can be far larger, even with a good test.

Worked example

Imagine 10,000 people, using the defaults: prior 1%, sensitivity 90%, false positive rate 5%.

  1. With the condition: 1% of 10,000 = 100 people; 90% test positive = 90 true positives.
  2. Without: 9,900 people; 5% test positive = 495 false positives.
  3. P(B) = (90 + 495) ÷ 10,000 = 5.85%.
  4. P(A|B) = 90 ÷ 585 = 15.38%. Only about one positive in six or seven is real.
  5. Negatives: 10 missed cases among 10,000 − 585 = 9,415 negatives, so P(A|not B) = 10 ÷ 9,415 = 0.11%.
How P(A|B) changes with P(B|not A) — false positive rate (%)How P changes with P(B|not A) — false po…010203040501.252.53.7556.257.510Example: 15.38%P(B|not A) — false positive rate (%)
Each point is the calculator re-run with only “P(B|not A) — false positive rate (%)” changed; the gold point is the default example. Change the inputs above and this chart follows your numbers.
P(B|not A) — false positive rate (%)P(A|B)
1.2542.11%
2.526.67%
3.7519.51%
515.38%
6.2512.7%
7.510.81%
108.33%

How to read the result

P(A|B) depends strongly on the prior. With the same test, a prior of 10% would give P(A|B) = 9 ÷ 13.5 ≈ 66.7%. This is why a positive screening result for a rare condition is usually followed by a second, more specific test, and why the same test means more in a high-risk group. P(A|not B) shows how reassuring a negative result is.

Common mistakes

Keep in mind: This is a probability illustration, not a diagnosis. Real test performance varies by population and setting, and the right prior for an individual depends on symptoms and risk factors that a clinician should assess.

Frequently asked questions

What happens if I test positive twice?

If the two tests are independent, use the first posterior (15.38%) as the new prior and apply the theorem again; with the same test it rises to about 76.6%.

What is the difference between PPV and sensitivity?

Sensitivity is P(positive | condition) and is a property of the test. PPV is P(condition | positive) and also depends on how common the condition is.

Sources: Sheldon M. Ross, A First Course in Probability, Pearson — conditional probability and Bayes' formula · Gerd Gigerenzer, Calculated Risks, Simon & Schuster — natural frequencies for test results

Checked 8 Nov 2026. Standard formulas, computed in your browser with double-precision numbers.

🧮 All math & statistics tools →🌍 Calculators by country →