insideout Get Pro

04 · Bayes' rule

Pro

Probability, lesson 4

Bayes' rule

Turning a test result into what you actually want to know.

A test is described by how often it's positive for people who have a condition. You want the reverse: how likely someone is to have it, given a positive. This lesson turns one into the other, using P(A | B) and splitting into cases from the last lesson.

By the end, you can:

  1. Find what a positive test means by counting a crowd.
  2. Turn P(B | A) into P(A | B) with Bayes' rule.
  3. Update a chance again and again as evidence arrives, using odds.

Part 1. A positive test

Find what a positive test means by counting a crowd.

Guess first

A condition affects 1 person in 100. A test for it is positive for 90% of people who have it, and for 9% of people who don't. Someone tests positive. How likely are they to have it?

Only about 9%. The example below counts it out: of the 981 people in 10,000 who test positive, 90 have the condition.

90% is how often the test catches a real case. The question asks something else: of everyone who tests positive, how many have the condition? Counts of people show it.

Example 1.1

A positive test, in people

1 person in 100 has a condition. A test is positive for 90% of people who have it and for 9% of people who don't. Picture 10,000 people taking it. What share of the positives have the condition?

  1. Split the crowd10,000 × 1% = 100

    100 people have the condition, and the other 9,900 don't.

  2. Positives who have it100 × 90% = 90

    The test catches 90 of the 100 real cases.

  3. Positives who don't9,900 × 9% = 891

    False alarms. A small rate on a big group is a lot of people.

  4. All the positives90 + 891 = 981

    Everyone who gets a positive result.

  5. Share who have it90 / 981 ≈ 0.092

    Only these 90 of the positives are real cases.

AnswerAbout 9%, not 90%.

Everyone The condition The test 1% 99% 90% 10% 9% 91% 10,000 100 have it 9,900 don't 90 positive 10 negative 891 positive 9,009 negative Positives: 90 + 891 = 981 Have it, given a positive: 90 / 981, about 9%
1% 99% 90% 10% 9% 91% 10,000 people 100 have it 9,900 don't 90 positive 10 negative 891 positive 9,009 negative Positives: 90 + 891 = 981 Have it: 90 / 981, about 9%
Figure 1The same test on 10,000 people. The 891 false alarms from the big group swamp the 90 real cases from the small one.

Why so low? The test runs on everyone, and people without the condition outnumber people with it 99 to 1. A 9% false alarm rate on 9,900 people makes 891 positives. A 90% hit rate on 100 people makes only 90, even though the rate is ten times higher.

Base rate, prior and posterior

How common something is before you see any evidence is its base rate, also called the prior: here 1%. The chance after the evidence is the posterior: here about 9%. Answering 90% leaves the base rate out, a mistake called base rate neglect.

P(has it | positive) = true positives / all positives

This is the last lesson's trap again, at higher stakes. P(positive | has it) = 90% and P(has it | positive) = 9% count the same 90 people over different bottoms: the 100 who have it, or the 981 who test positive. Tests are described by the first. The person holding the result needs the second.

Your turn

The same test is used where 1 person in 1,000 has the condition. A positive now means a chance of about:

Picture 100,000 people: 100 have it, and 90 test positive. 8,991 of the other 99,900 test positive too. So 90 / 9,081, about 1%. The rarer the condition, the more positives are false alarms.

Part 2. Bayes' rule

Turn P(B | A) into P(A | B) with Bayes' rule.

Keep going with Pro

You've done the first part. Pro opens the rest of this lesson, and every other one.

Still to come
  1. Bayes' rule
  2. Evidence that keeps coming

Probability overviewSpotted a mistake? Tell us.