All Tools

Bayes' Theorem Calculator

Enter a prior probability, true positive rate, and false positive rate to compute the posterior probability using Bayes' theorem. The tree diagram, contingency table, and natural frequency breakdown help you see why a positive test result does not always mean what you think it means.

Probability Tree

P(A) = 1.0%P(¬A) = 99.0%P(B|A) = 95.0%P(¬B|A) = 5.0%P(B|¬A) = 5.0%P(¬B|¬A) = 95.0%A¬AA ∩ B (TP)A ∩ ¬B (FN)¬A ∩ B (FP)¬A ∩ ¬B (TN)

Parameters

1.0%
95.0%
5.0%

Posterior Probability

P(A|B)
16.102%
P(B) total probability
5.9000%
P(not A)
99.0000%

Contingency Table

Test Positive (B)Test Negative (not B)Total
Has A955100
No A49594059900
Total590941010000

Natural Frequency

Out of 10,000 people:

Have condition (A)
100
Do not have condition
9,900

Of those who test positive (590 people):

True positives
95
False positives
495

So only 95 out of 590 positive results are actually correct.

Step-by-Step Calculation

1. Bayes' Theorem

P(AB)=P(BA)P(A)P(B)P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}

2. Total probability of B

P(B)=P(BA)P(A)+P(B¬A)P(¬A)P(B) = P(B|A) \cdot P(A) + P(B|\neg A) \cdot P(\neg A)

3. Substitute into P(B)

P(B)=(0.95)(0.01)+(0.05)(0.99)=0.059P(B) = (0.95)(0.01) + (0.05)(0.99) = 0.059

4. Compute posterior

P(AB)=(0.95)(0.01)0.059=0.161017P(A|B) = \frac{(0.95)(0.01)}{0.059} = 0.161017

5. As a percentage

P(AB)=16.102P(A|B) = 16.102%

Reference Guide

Bayes' Theorem

Bayes' theorem describes how to update a probability estimate when new evidence arrives. It relates the probability of a hypothesis given data to the probability of the data given the hypothesis.

P(AB)=P(BA)P(A)P(B)P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}

P(A)P(A) is the prior (your belief before evidence), P(BA)P(B|A) is the likelihood (how likely the evidence if the hypothesis is true), and P(AB)P(A|B) is the posterior (your updated belief).

Total Probability

The denominator P(B)P(B) is the total probability of observing the evidence. It accounts for both true positives and false positives.

P(B)=P(BA)P(A)+P(B¬A)P(¬A)P(B) = P(B|A)P(A) + P(B|\neg A)P(\neg A)

When the condition is rare (low prior), false positives can easily outnumber true positives. This is why the probability tree and contingency table are so useful for building intuition.

The Base Rate Fallacy

People often ignore the base rate (prior probability) and focus only on the test accuracy. A 95% accurate test sounds reliable, but when the condition is rare (say 1%), most positive results are actually false positives.

With 1% prevalence, 95% sensitivity, and 5% false positive rate, a positive result only means about a 16% chance of actually having the condition. This is why medical screening for rare diseases produces so many false alarms.

Natural Frequencies

Research shows that people understand Bayes' theorem much better when probabilities are presented as natural frequencies instead of percentages.

Instead of saying "the test has 95% sensitivity and 5% false positive rate," it is clearer to say "out of 10,000 people, 100 have the condition, and of those 100, 95 test positive. Of the 9,900 without the condition, 495 also test positive."

So out of 590 positive tests, only 95 are truly positive. That makes the 16% posterior probability much easier to see.