Bayes Theorem Calculator

The Bayes theorem calculator shows how likely an assumption A really is after a test or piece of evidence B. Example: with a 1% base rate, 90% sensitivity and 9% false alarms, a positive result is a true hit in only 9.17% of cases.

Example: Base rate P(A) 1 % · Sensitivity P(B|A) 90 % · False positive rate P(B|¬A) 9 % → Probability of A after a positive result: P(A|B) = 9.17%. Source: Wikipedia – Bayes’ theorem. Updated: .

%
How common A is without any test, e.g. prevalence of a disease
%
How often the test fires when A is true (hit rate)
%
How often the test fires although A is not true
My ToolboxYour inputs are saved in this browser only.

Result

Probability of A after a positive result
P(A|B) = 9.17%
Overall rate of the result
P(B) = 9.81%: how often the positive result occurs overall.
After a negative result
After a negative result A remains possible with 0.11% (negative predictive value 99.89%).
Likelihood ratios and odds
LR+ = 10, LR− = 0.1099; odds of A before 0.0101, after 0.101.
In natural frequencies
  • Out of 10,000 cases, A applies to 100 and does not apply to 9,900.
  • Of the 100 with A, the test fires for 90 (hits) and not for 10.
  • Of the 9,900 without A, the test fires for 891 (false alarms) and not for 9,009.
  • Overall the test fires for 981; of these really have A: 90 out of 981 = 9.17%.
Steps
  • P(B) = P(B|A) · P(A) + P(B|¬A) · P(¬A) = 0.9 · 0.01 + 0.09 · 0.99 = 0.0981
  • P(A|B) = P(B|A) · P(A) / P(B) = 0.9 · 0.01 / 0.0981 = 0.0917
  • P(A|¬B) = P(¬B|A) · P(A) / P(¬B) = 0.1 · 0.01 / 0.9019 = 0.0011

How it is calculated

Bayes' theorem calculates how likely an assumption A is after evidence B has been observed. It combines three numbers: how common A is without a test (base rate), how well the test detects A (sensitivity) and how often it fires wrongly (false positive rate).

The formula

P(A|B) = P(B|A) · P(A) / P(B), where P(B) = P(B|A) · P(A) + P(B|¬A) · P(¬A). The numerator holds the true hits, the denominator all positive results.

Example: a rare disease

1% of people have the disease, the test detects it in 90% of cases and fires wrongly for 9% of healthy people. Of 10,000 people, 100 are ill and 90 of them test positive. Of the 9,900 healthy people, 891 test positive. That is 981 positive tests in total, but only 90 come from ill people: 90 / 981 = 9.17%. Despite good test values, a positive result is mostly a false alarm because the disease is so rare.

A typical mistake

Many people confuse P(B|A) ("test positive if ill") with P(A|B) ("ill if test positive"). They are different numbers, and the base rate decides how far apart they are. Natural frequencies like those above make the difference easier to see.

Likelihood ratio

LR+ = sensitivity / false positive rate tells by what factor a positive result raises the odds of A. In the example LR+ = 10: the odds rise from 1 : 99 to 10 : 99.

Frequently asked questions

What does Bayes' theorem say?

It calculates how likely A is when B has been observed, from the base rate of A and the hit rates of B when A is true and when it is not.

Why is a positive test for a rare disease often a false alarm?

Because there are far more healthy than ill people: even a small false positive rate produces more false than true hits among the many healthy people.

What is the difference between sensitivity and positive predictive value?

Sensitivity P(B|A) is the hit rate among affected people. The positive predictive value P(A|B) tells how sure you can be of being affected after a positive test; it depends on the base rate.

What does the negative predictive value mean?

It shows how sure you can be of not being affected after a negative result. For rare conditions it is usually very high.

What is Bayes' theorem used for outside medicine?

For example in spam filters, quality control, alarm systems or forensic evidence – wherever an error-prone indicator points to a rare cause.

Sources and legal basis

As of: · Editorial policy

Related tools