Statistics & Probability · Grades 11, 12

Bayes' Theorem: Updating Probabilities with Evidence

Quick answer

Bayes' theorem reverses a conditional probability: from how likely the evidence is when a cause is present, it finds how likely the cause is once the evidence is seen. P(A | B) = P(B | A) · P(A) / P(B), where P(B) adds up every way B can happen. Counting a large imaginary group, the natural frequency method, makes the same calculation concrete and shows why a rare condition plus a small error rate produces many false alarms.

What you'll learn

  • State and apply Bayes' theorem
  • Find a total probability by adding the ways an event can happen
  • Use natural frequencies to check a Bayes calculation
  • Explain the base-rate effect in medical and quality testing

Reversing a conditional probability

A disease affects 1%1\% of people. A test detects it 95%95\% of the time, and gives a false positive for 5%5\% of healthy people. You test positive. How likely is it that you have the disease?

The test’s accuracy is P(+∣D)=0.95P(+ \mid D) = 0.95. The question asks for the reverse, P(D∣+)P(D \mid +). Conditional probabilities are not symmetric, and Bayes’ theorem converts one into the other:

P(D∣+)=P(+∣D) P(D)P(+)P(D \mid +) = \frac{P(+ \mid D)\,P(D)}{P(+)}

The denominator adds every way to test positive, the sick and the healthy:

P(+)=P(+∣D)P(D)+P(+∣not D)P(not D)=0.95(0.01)+0.05(0.99)=0.059P(+) = P(+ \mid D)P(D) + P(+ \mid \text{not } D)P(\text{not } D) = 0.95(0.01) + 0.05(0.99) = 0.059

So P(D∣+)=0.00950.059≈0.161P(D \mid +) = \tfrac{0.0095}{0.059} \approx 0.161. Despite the positive result, the chance of having the disease is about 16%16\%.

Why the answer is so low: count a crowd

Picture 10,00010{,}000 people.

Test positiveTest negativeTotal
Have the disease959555100100
Healthy4954959,4059{,}4059,9009{,}900
Total5905909,4109{,}41010,00010{,}000

Of the 590590 positives, only 9595 are sick: 95590≈0.161\tfrac{95}{590} \approx 0.161. The test’s error rate is small, but it applies to a huge group of healthy people, so the false positives outnumber the true ones. This is the base-rate effect: the rarer the condition, the more a positive result is likely to be a false alarm. The formula and the crowd are the same calculation, and the crowd is often the clearer way to see it.

Worked examples

Common mistakes

Practice problems

  1. A condition affects 10%10\% of people. A test catches 90%90\% of cases and falsely flags 10%10\% of healthy people. Find P(condition∣+)P(\text{condition} \mid +).

    Answer

    0.50.5

    Full solution

    0.9(0.1)0.9(0.1)+0.1(0.9)=0.090.18\tfrac{0.9(0.1)}{0.9(0.1) + 0.1(0.9)} = \tfrac{0.09}{0.18}.

  2. 40%40\% of emails are spam. A word appears in 30%30\% of spam and 2%2\% of other emails. An email contains the word. What is the chance it is spam?

    Answer

    About 0.9090.909

    Full solution

    0.3(0.4)0.3(0.4)+0.02(0.6)=0.120.132\tfrac{0.3(0.4)}{0.3(0.4) + 0.02(0.6)} = \tfrac{0.12}{0.132}.

  3. 2%2\% of items are defective. An inspection flags 99%99\% of defective items and 3%3\% of good ones. An item is flagged. What is the chance it is defective?

    Answer

    About 0.4020.402

    Full solution

    0.99(0.02)0.99(0.02)+0.03(0.98)=0.01980.0492\tfrac{0.99(0.02)}{0.99(0.02) + 0.03(0.98)} = \tfrac{0.0198}{0.0492}.

  4. In the opening example, out of 10,00010{,}000 people, how many test negative but are sick?

    Answer

    55

    Full solution

    Of the 100100 sick, 95%95\% test positive, so 55 test negative.

  5. In Example 1, what is the chance a defective part came from machine A?

    Answer

    0.3750.375

    Full solution

    0.6(0.02)0.032\tfrac{0.6(0.02)}{0.032}, or 1−0.6251 - 0.625.

  6. Explain why P(D∣+)P(D \mid +) rises if the disease becomes more common, with the same test.

    Answer

    More true positives come from the larger sick group, and fewer false ones from the smaller healthy group.

    Full solution

    With 10%10\% prevalence the same test gives 0.0950.095+0.045≈0.68\tfrac{0.095}{0.095 + 0.045} \approx 0.68, compared with 0.160.16 at 1%1\%.

  7. In Example 3, a blue ball is drawn instead. What is the chance it came from urn 1?

    Answer

    14\tfrac{1}{4}

    Full solution

    12⋅1412⋅14+12⋅34\tfrac{\tfrac{1}{2} \cdot \tfrac{1}{4}}{\tfrac{1}{2} \cdot \tfrac{1}{4} + \tfrac{1}{2} \cdot \tfrac{3}{4}}.

  8. A student reads “the test is 95%95\% accurate” and concludes a positive result means a 95%95\% chance of disease. What is wrong?

    Answer

    That reverses the conditional probability. With 1%1\% prevalence the chance is about 16%16\%.

    Full solution

    95%95\% is P(+∣D)P(+ \mid D). The question asks for P(D∣+)P(D \mid +), which depends on the base rate.

Frequently asked questions

What is Bayes' theorem?

P(A | B) = P(B | A) · P(A) / P(B). It turns the probability of the evidence given a cause into the probability of the cause given the evidence.

How do you find P(B) in the denominator?

Add every way B can happen: P(B) = P(B | A)P(A) + P(B | not A)P(not A). This is the law of total probability.

Why can a positive test mean a low chance of disease?

When a disease is rare, the few true positives are outnumbered by false positives from the many healthy people, even if the test is accurate.

What are prior and posterior probabilities?

The prior is the probability before the evidence, such as the 1% prevalence. The posterior is the updated probability after it, such as P(disease | positive).

What are natural frequencies?

Imagining a concrete group, say 10,000 people, and counting how many fall into each case. It gives the same answer as the formula with whole numbers instead of decimals.

What to learn next

Standards alignment

This lesson covers the following Common Core State Standards for Mathematics.

  • CCSS.MATH.CONTENT.HSS.CP.A.3Conditional Probability and the Rules of ProbabilityUnderstand the conditional probability of A given B as P(A and B)/P(B), and interpret independence of A and B as saying that the conditional probability of A given B is the same as the probability of A, and the conditional probability of B given A is the same as the probability of B.
  • CCSS.MATH.CONTENT.HSS.CP.B.6Conditional Probability and the Rules of ProbabilityFind the conditional probability of A given B as the fraction of B's outcomes that also belong to A, and interpret the answer in terms of the model.