Bayes' Theorem Calculator
Test cases replayed : 3 of 3 match · Methodology · No outside source listed
Enter the prior probability of A and the probability of the evidence B with and without A, as numbers between 0 and 1.
Result
P(A | B), posterior probability
P(B), total probability of B
- P(A | not B)
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- Prior probability P(A) (0 to 1): enter a number from 0 to 1.
- P(B | A), probability of B when A is true: enter a number from 0 to 1.
- P(B | not A), probability of B when A is false: enter a number from 0 to 1.
- Read the result: P(A | B), posterior probability; the panel also shows P(B), total probability of B and P(A | not B).
How this calculator works
Bayes' theorem: P(A | B) = P(B | A) × P(A) ÷ P(B), where the law of total probability gives P(B) = P(B | A) × P(A) + P(B | not A) × (1 − P(A)).
In a screening example, A is having the condition, B a positive result, P(B | A) the sensitivity and P(B | not A) the false positive rate (1 − specificity).
The formula
| Symbol | Meaning |
|---|---|
| Prior probability P(A) (0 to 1) | |
| P(B | A), probability of B when A is true | |
| P(B | not A), probability of B when A is false | |
| P(B), total probability of B | |
| P(A | B), posterior probability |
Worked example
| Prior probability P(A) (0 to 1) | 0.01 |
|---|---|
| P(B | A), probability of B when A is true | 0.9 |
| P(B | not A), probability of B when A is false | 0.05 |
| P(B), total probability of B | 0.0585 |
|---|---|
| P(A | not B) | 0.0011 |
P(A | B), posterior probability 0.1538
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
If 1% have a condition and a test is 90% sensitive with 5% false positives, what does a positive mean?
P(A | B) = 0.009 ÷ 0.0585 ≈ 0.1538: about a 15% chance, because false positives outnumber true ones.
What is the difference between P(A | B) and P(B | A)?
They answer different questions and are usually different numbers; Bayes' theorem converts one into the other using P(A) and P(B).