Update a probability in the light of new evidence. Enter how likely something was to begin with and how reliable the evidence is, and see how likely it is now, with the working shown as counts out of 10,000.
P(A | B) = P(B | A) × P(A) ÷ P(B)
How likely A is before the evidence, such as how common a disease is.
How often the evidence shows up when A is true (a test's sensitivity).
How often it shows up anyway when A is false (the false-positive rate).
As a decimal (0.25), a percentage (25%) or a fraction (1/4).
Bayes' theorem tells you how to update a probability when new evidence arrives. You start with a prior (how likely something was beforehand), weigh how much more often the evidence turns up when it's true than when it isn't, and end with a posterior.
Its most famous use is reading medical test results. A test that catches 95% of cases sounds decisive, but if the disease is rare, the healthy people who test positive by mistake can far outnumber the sick people who test positive correctly.
The same reasoning runs spam filters, forensic evidence, A/B tests and machine learning. It's the formal way to turn P(evidence | cause), which is what experiments measure, into P(cause | evidence), which is what you actually want to know.
Formula as given in Blitzstein and Hwang; natural-frequency presentation after Gigerenzer and Hoffrage (1995). See Sources.
True positives plus false positives: the law of total probability.
The likelihood ratio measures how strong the evidence is on its own, separately from how likely A was to start with.
Most positives are false alarms, because the 5% error rate is applied to a far bigger healthy group. The positive still matters: it raised the chance sixteenfold, from 1% to 16%, which is why a second, independent test usually follows.
The same 95% / 5% test from the worked example, used on groups where the disease is more or less common.
| Prior | After a positive | After a negative |
|---|---|---|
| 0.1% | 1.87% | 0.005% |
| 1% | 16.1% | 0.053% |
| 10% | 67.86% | 0.581% |
| 50% | 95% | 5% |
Your best estimate of the probability before seeing the evidence. For a screening test it’s usually the prevalence in the group being tested.
Use the first posterior as the new prior. A second positive from an independent 95% / 5% test takes the example from 16.1% to about 78.5%.
P(B | A) ÷ P(B | not A): how many times more often the evidence appears when A is true. A ratio of 19 multiplies the prior odds by 19.
When the prior is low and the test is sensitive, a negative leaves very little chance of disease: about 0.05% in the example. Negatives and positives carry different weight.
No. Any time you want P(cause | evidence) from P(evidence | cause) it applies: spam filtering, fraud detection, forensic evidence, fault diagnosis.
Yes. 1%, 0.01 and 1/100 all mean the same.
Then the evidence never appears without A, so seeing it makes A certain. The likelihood ratio shows as infinite.
Both accept Bayes’ theorem. Bayesian statistics goes further and uses it to update beliefs about unknown quantities themselves, such as a drug’s true effect.
Related Tools
Basic probability calculations.
P(A|B) calculations.
P(A and B) calculations.
Three event probabilities.
Probability-weighted average.
Decision theory.