Skip to content

← Math Further 9–12

Is a Positive Test Result Bad News?

Topic 14 · Grades 9–12 · Base rates and Bayes’ rule

What this builds on from class
In this unit 10 sections
  1. Count the people
  2. Two questions that sound alike
  3. Bayes’ rule
  4. Who is being tested?
  5. Test again
  6. Even doctors find it hard
  7. Courts and inboxes
  8. A story from maths
  9. Questions
  10. Where to go next

A health camp has come to a school in Bhaktapur, and every student in the hall is being checked for a rare condition. (It is made up, so that we can choose easy numbers; real tests come later.) One person in every 1,000 has it. The test is good: it says “positive” to 99 of every 100 people who have the condition, and it wrongly says “positive” to only 1 of every 100 who don’t. The poster on the wall calls it “99% accurate”.

Pasang’s slip comes back marked positive. His friends go quiet. Ninety-nine percent accurate, and it says yes: surely he has it?

Before you read on, make your guess. Then the next section lets you count.

Guess first. Pasang has tested positive. What is the chance that he really has the condition?

Pick an answer to see why.

Count the people

Chances are hard to picture; people are easy. So think of a whole crowd.

Try it

Test a crowd of 1,000

Each dot is a person. The red dots have the condition; a dark ring means the test said positive. Look at who is ringed, then make the condition commoner, the false alarms rarer, or test the positives again.

Has it:
False alarms:
Ringed (positive)
11
Of them, have it
1
A positive has it
9.0%

Just 1 of the 11 ringed people has it: about 1 in 11. The other 10 are false alarms.

Only 2 people are ringed now: 1 has it, the other is a false alarm.

1 of the 11 ringed people have it: about 1 in 11. The other 10 are false alarms.

1 of the 11 ringed people have it: about 1 in 11. Just one is a false alarm.

Only people who have it are still ringed here. A healthy person gets two false alarms in about one crowd like this in ten, so the chance is 9.0%, not 100%.

Everyone still ringed has it. A false alarm twice in a row is now very rare.

In a crowd of 1,000 people, about 1 has the condition, and the test almost surely catches them. The other 999 are healthy, and 1 in 100 of them gets a false alarm: about 10 people. So about 11 people are ringed, and only 1 of them has it. A positive result puts you in that ringed group, and in that group the chance of having the condition is about 1 in 11.

A crowd of 1,000 is too small for exact counts (a test can’t catch 0.99 of a person), so take 100,000 people, where every count comes out whole. This is a tree diagram, as in Grade 10, but with the number of people on each branch instead of the probability: these numbers are called natural frequencies, or expected frequencies.

1 in 1,000999 in 1,00099%1%1%99%100,000 people100have it99,900don’t99positive1negative999positive98,901negativePositive: 99 + 999 = 1,098 people.Of them 99 have it: 99 ÷ 1,098 ≈ 9%.
Figure 14.1 100,000 people tested. One in 1,000 has the condition: 100 people. The test is positive for 99% of them (99 people) and, wrongly, for 1% of the 99,900 who don’t (999 people). The positives, tinted, add up to 1,098, and 99 of them have it.

Read the bottom row of Figure 14.1. Everyone who tests positive is in one of the two tinted boxes: 99 people who have the condition and 999 who don’t. So

P(has it, given a positive)=9999+999=991,098≈0.090, P(\text{has it, given a positive}) = \frac{99}{99 + 999} = \frac{99}{1{,}098} \approx 0.090,

about 9%. Pasang is far more likely to be one of the 999 than one of the 99.

Nothing is wrong with the test: it gives the right answer to 99,000 of the 100,000 people. But almost all of the 1,000 it is wrong about are healthy people with a false alarm, because healthy people are 999 in every 1,000 of the crowd.

In the tree, which number decides most of the answer?

Pick an answer to see why.

Two questions that sound alike

Here is the whole trick in one line. “The test is 99% accurate” answers one question, and Pasang is asking a different one:

  • Of the people who have the condition, how many test positive? 99%.
  • Of the people who test positive, how many have the condition? 9%.

The two questions use the same words in a different order, and their answers are eleven times apart. In the notation of probability, a vertical bar is read “given”: P(A∣B) P(A \mid B) is the chance of A given that B has happened, a conditional probability. Then the two questions are

P(positive∣has it)=0.99,P(has it∣positive)≈0.09. P(\text{positive} \mid \text{has it}) = 0.99, \qquad P(\text{has it} \mid \text{positive}) \approx 0.09.

Mixing them up, by forgetting how rare the condition is (its base rate), is so common that it has a name: the base rate fallacy.

You already know these two questions are different when the words are everyday ones. Almost everyone who lives in Bhaktapur is Nepali: P(Nepali∣lives in Bhaktapur) P(\text{Nepali} \mid \text{lives in Bhaktapur}) is nearly 1. But only a small share of Nepalis live in Bhaktapur: P(lives in Bhaktapur∣Nepali) P(\text{lives in Bhaktapur} \mid \text{Nepali}) is small. Nobody mixes those up. A test result hides the same difference behind numbers that sound medical.

Reading it from a table

Results like these are often written as a two-way table: one way across for the condition, the other for the test. Here is a different test, for a condition that 1 in 100 people have; it catches 90% of them, and gives false alarms to 5% of the rest. For 10,000 people:

Test positive Test negative Total
Has it 90 10 100
Doesn’t 495 9,405 9,900
Total 585 9,415 10,000

Each conditional probability is a share of one row or one column. Given that a person has it, you are in the first row, so P(positive∣has it)=90÷100=90% P(\text{positive} \mid \text{has it}) = 90 \div 100 = 90\% . Given a positive result, you are in the first column, so P(has it∣positive)=90÷585≈15% P(\text{has it} \mid \text{positive}) = 90 \div 585 \approx 15\% . Same corner cell, 90 people, divided by a different total.

That is the general rule. Out of everyone for whom B happens, what share also has A?

P(A∣B)=P(A and B)P(B). P(A \mid B) = \frac{P(A \text{ and } B)}{P(B)}.

With the table’s numbers, 90/10,000585/10,000 \frac{90/10{,}000}{585/10{,}000} : the 10,000s cancel, leaving 90 ÷ 585 again. Counting people and the formula are the same calculation.

The table also shows that having the condition and testing positive are not independent events. Over everyone, P(has it) = 100 ÷ 10{,}000 = 1%; among the positives it is 15%. Two events are independent when knowing that one has happened doesn’t change the chance of the other, P(A∣B)=P(A) P(A \mid B) = P(A) , as in Grade 10. A test is worth taking only because its result is not independent of the condition.

In the table above, what is P(negative∣doesn’t have it) P(\text{negative} \mid \text{doesn’t have it}) ?

Pick an answer to see why.

Bayes’ rule

The tree and the table did everything by counting. Write the same counting with letters and you get a formula that works for any test. Call the base rate p (the share who have the condition), the share of them the test catches s, and the false alarm rate f (the share of healthy people who test positive). Out of N people,

  • those who have it and test positive: Nps;
  • those who don’t and test positive: N(1 − p)f.

A positive result means you are one of these, so

P(has it∣positive)=p sp s+(1−p) f. P(\text{has it} \mid \text{positive}) = \frac{p\,s}{p\,s + (1 - p)\,f}.

This is Bayes’ rule (also called Bayes’ theorem), after Thomas Bayes (below). With p = 0.001, s = 0.99, f = 0.01: 0.00099÷(0.00099+0.00999)≈0.090 0.00099 \div (0.00099 + 0.00999) \approx 0.090 , Pasang’s 9%.

In medicine the three numbers have names. The share of those with the condition whom the test catches, s, is the test’s sensitivity. The share of healthy people it correctly clears, 1 − f, is its specificity: a false alarm rate of 1% is a specificity of 99%. The base rate is the condition’s prevalence. And the answer, the chance that a positive is real, is the positive predictive value. “99% accurate” meant a sensitivity and a specificity of 99%; the positive predictive value depends on the prevalence too.

The quick way: odds

There is a way to do Bayes’ rule in your head. Instead of a chance, use odds: the number of people who have it against the number who don’t. Before the test, the odds are 1 to 999 (written 1 : 999).

Now ask how much more likely a positive result is from someone who has it than from someone who doesn’t: s ÷ f = 0.99 ÷ 0.01 = 99 times. This number, the likelihood ratio of a positive result, belongs to the test alone. A positive result multiplies the odds by it:

1:999→ ×99 99:999. 1 : 999 \quad \xrightarrow{\ \times 99\ } \quad 99 : 999.

Why does multiplying work? Of N people, those who test positive are Nps who have it and N(1 − p)f who don’t, so the odds among the positives are

Nps:N(1−p)f  =  p×sf:(1−p), N p s : N (1 - p) f \;=\; p \times \frac{s}{f} : (1 - p),

the odds before the test, p:(1 − p), with the first side multiplied by s ÷ f.

Odds of 99 to 999 are a chance of 99 ÷ (99 + 999) = 99 ÷ 1,098, the 9% again. The 99 people and 999 people are the tree’s two tinted boxes. The test multiplied the odds by 99, which is a lot; but they started at 1 to 999, so after one positive they are still about 1 to 10 against.

Who is being tested?

The last answer is worth stopping on. A positive result from one and the same test means 9% in a school hall and 92% in a clinic. The test hasn’t changed; the people have. Before you can say what a result means, you must know who was tested and how common the condition is among them.

Try it

The same test, different groups

The curves show the chance that a positive result is real, for groups where the condition is rare (left) or common (right). Move the slider to choose the group, and switch to a better test with false alarms of 1 in 1,000.

0%25%50%75%100%100,00010,0001,000100102chance that a positive has ithow many have it: 1 in …two positivesone positive
False alarms:
After one positive
9.02%
After two positives
90.8%

Most positives are false alarms: the healthy people are so many that their few mistakes outnumber the real cases.

A positive is a real warning now, but still more often wrong than right. A second test is needed.

Now a positive is more often right than wrong: the real cases outnumber the false alarms.

Here nearly every positive is real: the condition is common enough to swamp the false alarms.

Where 1 in 100,000 people have the condition, about a thousand false alarms come with every real case, and one positive means almost nothing (0.10%). At 1 in 100, real cases and false alarms are equal in number: an even chance. At 1 in 10 it is 92%. That is why a doctor asks about your symptoms before ordering a test: the answers change the base rate, and so what the result will mean.

A better test moves the whole curve to the left. With false alarms of 1 in 1,000 (a specificity of 99.9%), a positive in the school hall means about 50% instead of 9%. For a positive to be more likely right than wrong where 1 in 1,000 have the condition, the false alarm rate has to be a little below 1 in 1,000: the test must be at least as rare in its mistakes as the condition is in the crowd.

Test again

What happens if every positive is tested a second time? Go back to the crowd at the top of the page and press Test the positives again. Of the 1,098 positives in 100,000 people, a second positive comes for 99% of the 99 who have it (98 people) and for only 1% of the 999 false alarms (10 people). Now 98 of 108 have it: about 91%.

In odds, each independent positive multiplies by the likelihood ratio again:

Odds (has it : doesn’t) Chance
Before any test 1 : 999 0.1%
After one positive 99 : 999, about 1 : 10 9.0%
After two positives 9,801 : 999, about 10 : 1 90.8%
After three positives 970,299 : 999, about 971 : 1 99.9%

The first positive turned 1 in 1,000 into 1 in 11; the second turned that into 10 in 11. The same multiplication, ×99, did both, but it starts each time from what the last test left.

Even doctors find it hard

If this was surprising, you are in good company. In 2007 the psychologist Gerd Gigerenzer gave 160 gynecologists, doctors who need exactly this number to explain a screening result, this problem at the start of a training session: 1% of the women in a region have breast cancer; a mammogram (an X-ray screening test) is positive for 90% of those who have it, and for 9% of those who don’t. A woman tests positive. Is the chance that she has breast cancer about 81%, about 9 in 10, about 1 in 10, or about 1%?

The answer, which you can now work out, is about 1 in 10 (with Bayes’ rule, 9.2%). Most of the doctors chose 90% or 81%, their answers ran all the way from 1% to 90%, and only 21% chose the right one, fewer than would have by picking at random. Then the session taught them to turn such percentages into natural frequencies: of 1,000 women, 10 have cancer, and 9 of them test positive; of the 990 who don’t, about 89 test positive. Afterwards, 87% of them chose 1 in 10.

So the difficulty isn’t in people’s heads so much as in the way the numbers are given. Percentages of percentages are hard; people are easy to count. Gigerenzer and his colleagues report the same pattern from other studies: in one from 1978, only 18% of the doctors and medical staff asked could work out the chance that a positive result was real.

In Gigerenzer’s problem, the doctors’ favorite answers were 90% and 81%. What makes both of them wrong, whatever the working behind them?

Pick an answer to see why.

Courts and inboxes

In a courtroom the mix-up is called the prosecutor’s fallacy: reading “how likely is this evidence if the person is innocent?” as “how likely is the person to be innocent, given this evidence?”. A trace that matches only 1 person in 1,00,000 by chance sounds damning, but in a city of ten lakh about 10 other people would match it too (Question f).

In your inbox, the mix-up is avoided on purpose. In 2002 the programmer Paul Graham described a spam filter that learns, from mail a person has already sorted, how often each word turns up in spam and in other mail, and combines the words of a new message by Bayes’ rule into the chance that it is spam. In his mail, the word “guarantee” meant about a 98% chance of spam; he treated a message as spam above 90%. Graham reported that, on his own mail, his filter missed fewer than 5 in every 1,000 spams, with no good mail wrongly caught.

A story from maths

Questions

★ A condition affects 1 in 50 people. A test catches 90% of them and gives false alarms to 5% of those who don’t. About what is the chance that a positive result is real?

Pick an answer to see why.

a.★

Use the two-way table in “Reading it from a table” (10,000 people, 1 in 100 with the condition). Find P(positive), P(has it∣negative) P(\text{has it} \mid \text{negative}) and P(doesn’t have it∣positive) P(\text{doesn’t have it} \mid \text{positive}) . Say in words what the last one means.

Hint
Answer
b.★★

In a fever clinic, 1 patient in 10 has a certain infection. A quick test catches 90% of infections and correctly clears 95% of patients who don’t have it. Draw a tree for 1,000 patients and find the chance that a patient with a positive result has the infection, and the chance that a patient with a negative result has it.

Hint
Answer
c.★★

Half of the mail that reaches an inbox is spam. The word “lottery” appears in 20% of the spam and in 0.5% of the other mail. A new message contains “lottery”. What is the chance that it is spam? What if only 1 message in 10 were spam?

Hint
Answer
d.★★

Pasang’s condition affects 1 in 1,000 people and his test catches 99% of them. The makers want a positive result to be right at least half the time. What is the largest false alarm rate they can allow? What specificity is that?

Hint
Answer
e.★★★

A shop buys its mangoes from three farms: 50% from farm A, 30% from farm B and 20% from farm C. Of A’s mangoes 2% are bad, of B’s 5%, and of C’s 10%. A customer finds a bad mango. Which farm is it most likely from, and with what chance?

Hint
Answer
f.★★★

In a city of 10,00,000 people, a crime leaves a trace that would match 1 person in 1,00,000 by chance. The police test a man picked only because he lives in the city, and his trace matches. A newspaper writes: “The chance that he is innocent is 1 in 1,00,000.” What is wrong, and what is a better estimate of the chance that he is the one, if there is no other evidence?

Hint
Answer

Where to go next

Where these facts come from
  • The gynecologists’ problem (2007, 160 gynecologists; 1%, 90%, 9%; the four answers; most answering 90% or 81%; estimates from 1% to 90%; 21% right; the natural-frequency version with 10, 9, 990 and 89; 87% right after training) and the 1978 study’s 18% (Casscells, Schoenberger and Graboys, New England Journal of Medicine 299 (1978), as these authors report it; the paper itself not opened): G. Gigerenzer, W. Gaissmaier, E. Kurz-Milcke, L. M. Schwartz and S. Woloshin, “Helping Doctors and Patients Make Sense of Health Statistics”, Psychological Science in the Public Interest 8 (2007), 53–96, read October 2026.
  • WHO’s 99% positive predictive value, three consecutive reactive tests below 5% positivity, and the move from two to three: World Health Organization, Consolidated guidelines on HIV testing services for a changing epidemic, policy brief, November 2019, read October 2026.
  • Sally Clark (solicitor, convicted 1999, 1 in 73 million from 1 in 8,543 squared, the Royal Statistical Society’s point about genetic or environmental factors and its words of January 2002, convictions overturned at the second appeal in January 2003, undisclosed microbiology results): Wikipedia, “Sally Clark”, read October 2026. The names base rate fallacy and prosecutor’s fallacy: Wikipedia, “Base rate fallacy”, read October 2026.
  • The spam filter (August 2002, a Bayesian combination of words’ spam probabilities, “guarantee” at 0.976, the 0.9 threshold, under 5 in 1,000 spams missed with no false positives): Paul Graham, “A Plan for Spam”, read October 2026. That Bayesian filters spread after it is our summary, not his.
  • Thomas Bayes (minister at Tunbridge Wells from about 1733, Fellow of the Royal Society 1742, died 1761, Price’s letter, the essay printed in 1764, Laplace accepting his results in 1781): MacTutor, “Thomas Bayes”, read October 2026. Price’s two years of editing, the reading on 23 December 1763, Laplace’s independent work of 1774 and his Théorie analytique des probabilités (1812), Stigler’s 1983 case for Nicholas Saunderson and that it is disputed, and the rule in its medical-test form: Wikipedia, “Bayes’ theorem”, read October 2026.
  • Every number on this page (the crowd and the tree, 99/1,098, the table of 10,000, the 2% example, the odds table, 92% in the clinic, the base-rate curve’s values, the negative results, 49.8% and 1 in 1,009, Gigerenzer’s 9.2% and 81%, the city of ten lakh, and every answer to the questions) was computed by a script (checks/textbooks/math-further-9-12/14/tmp/answers.py).