Bayes Theorem
Photo by Daniel Sone / National Cancer Institute on Unsplash, cropped.
Bayes' theorem (or Bayes' rule) allows us to update the probability of an event based on new evidence.
It builds on Conditional Probability. The basic form is:
The prior is the probability before considering the new evidence. The posterior is the updated probability after considering it.
Example: A Positive Disease Test
Let's say we want to compute the probability that a person has a disease, given that they test positive for it:
We'll use these illustrative figures:
- of the population has the disease: .
- The test returns a positive result for of people with the disease: .
- The test also returns a positive result for of people without the disease: .
The figure is our prior. The figure is the likelihood of a positive result given the disease. The figure is the false-positive rate.
Using Bayes' theorem:
The denominator is the probability of getting a positive test result overall, whether or not the person has the disease. This is what evidence means in the formula.
Calculating the Probability of a Positive Test
The only value we don't yet know is .
A positive result can come from someone with the disease or someone without it. These cases are mutually exclusive and cover all positive results, so we can use the Addition Rule of Probability:
Then we apply the general multiplication rule to each term:
This is the law of total probability, which we used for total enumeration in Conditional Probability.
Since , substituting our values gives:
Updating the Probability of Disease
Now we can fill in the denominator:
Under these assumptions, a positive result raises the probability of having the disease from to about .
The result is still relatively low because the disease is rare and false positives are common. In an imaginary population of 10,000 people with exactly these proportions, 90 people with the disease and 1,485 people without it would test positive. Only 90 of the 1,575 positive results would be from people with the disease.
General Form
For general events and , Bayes' theorem is:
This requires . If is not already known, we can expand it using the law of total probability:
Here, is the Complement Rule of , meaning that does not occur, and . The expanded form assumes both cases have nonzero probability so their conditional probabilities are defined.
Use the shorter formula when the denominator is already known. Otherwise, calculate it separately or use the expanded form. Both approaches give the same result.