Mathwords logoReference LibraryMathwords

Bayes' Theorem

Bayes' Theorem is a formula that lets you update the probability of an event based on new information or evidence. It answers the question: given that something has already happened, how likely is it that a particular cause was responsible?

Bayes' Theorem provides a method for computing the posterior probability P(AB)P(A \mid B) — the probability of event AA given that event BB has occurred — using the prior probability of AA, the likelihood of BB given AA, and the total probability of BB. It is derived directly from the definition of conditional probability and the law of total probability. The theorem is foundational in statistical inference, where it allows us to revise beliefs as new data becomes available.

Key Formula

P(AB)=P(BA)P(A)P(B)P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)}
Where:
  • P(AB)P(A \mid B) = the posterior probability of A given that B has occurred
  • P(BA)P(B \mid A) = the likelihood — the probability of observing B if A is true
  • P(A)P(A) = the prior probability of A before observing B
  • P(B)P(B) = the total probability of B across all possible causes

Worked Example

Problem: A disease affects 1% of a population. A test for the disease is 95% accurate: it correctly identifies a sick person 95% of the time (sensitivity) and correctly identifies a healthy person 90% of the time (specificity). If a person tests positive, what is the probability they actually have the disease?
Step 1: Define the events and identify the known probabilities.
P(D) = 0.01$, $P(\text{Pos} \mid D) = 0.95$, $P(\text{Pos} \mid D^c) = 0.10
Step 2: Calculate the total probability of testing positive using the law of total probability.
P(Pos)=P(PosD)P(D)+P(PosDc)P(Dc)=(0.95)(0.01)+(0.10)(0.99)=0.0095+0.099=0.1085P(\text{Pos}) = P(\text{Pos} \mid D) \cdot P(D) + P(\text{Pos} \mid D^c) \cdot P(D^c) = (0.95)(0.01) + (0.10)(0.99) = 0.0095 + 0.099 = 0.1085
Step 3: Apply Bayes' Theorem to find the probability of having the disease given a positive test.
P(DPos)=P(PosD)P(D)P(Pos)=(0.95)(0.01)0.1085=0.00950.10850.0876P(D \mid \text{Pos}) = \frac{P(\text{Pos} \mid D) \cdot P(D)}{P(\text{Pos})} = \frac{(0.95)(0.01)}{0.1085} = \frac{0.0095}{0.1085} \approx 0.0876
Answer: There is roughly an 8.8% chance the person actually has the disease, even after testing positive. The low prior probability (1%) means most positive results are false positives.

Why It Matters

Bayes' Theorem is central to medical testing, spam filters, machine learning, and forensic analysis — anywhere you need to interpret evidence. In AP Statistics, it appears in questions about diagnostic tests and two-way tables. The medical testing example above shows why understanding Bayes' Theorem matters: without it, a 95%-accurate test might make you think a positive result is almost certain proof of disease, when the actual probability can be surprisingly low.

Common Mistakes

Mistake: Confusing P(AB)P(A \mid B) with P(BA)P(B \mid A)
Correction: These are not the same. The probability of testing positive given you have a disease is very different from the probability of having the disease given a positive test. This mix-up is so common it has a name: the prosecutor's fallacy.
Mistake: Forgetting to account for the full denominator P(B)P(B)
Correction: You must include all the ways BB can happen — not just the case where AA is true. Use the law of total probability: P(B)=P(BA)P(A)+P(BAc)P(Ac)P(B) = P(B \mid A)P(A) + P(B \mid A^c)P(A^c).

Related Terms