AZTest
Probability study guide · step 5 of 6

Bayes' theorem word problems: medical tests, spam and witnesses

A test that is 95% accurate can still give mostly false alarms when the illness is rare. Bayes' theorem turns P(positive | ill) round into P(ill | positive) by weighing every way a positive result can happen.

Key ideas

Watch out: The false positive rate is P(+ | well), not P(well | +).

Practise this step

5 questions from this step only, in 8 minutes: new numbers and stories every time, of exactly the types worked out below. Marked at the end, with every question worked out.

Start the 5-question quiz

Every question type in this step, worked out

9 types of question. Try each one yourself before you open the hint or the solution.

Example 1 · level 8

A town tests all of its 40,000 people for an illness that 2% of them have. The test is positive for 98% of the people who have the illness and for 3% of those who do not. What fraction of the positive results, as a decimal, belongs to people who do not have the illness?

N = 40,0002 %ill98 %+−98 %healthy3 %+−P = ?
Hint

Count the people: first ill and not ill, then the positives in each group.

Worked solution
N = 40,0002 %ill98 %+−98 %healthy3 %+−= 800= 39,200= 784= 1176P = 0.6
N(1−p)fNps+N(1−p)f
  1. Ill: 2% × 40,000 = 800; not ill: 40,000 − 800 = 39,200
  2. Positive: 98% × 800 = 784 ill and 3% × 39,200 = 1176 not ill, 1960 in all
  3. 1176/1960 = 0.6

Answer: 0.6

Example 2 · level 9

Box A holds 8 balls, of which 4 are red; box B holds 10 balls, 7 of them red; box C holds 5 balls, 4 of them red. One of the boxes is picked at random, and a ball is taken from it at random. The ball is red. What is the probability that it came from box A?

A4n = 8B7n = 10C4n = 5P = ?
Hint

Each box is picked with probability one third, so the third cancels: compare the shares of red.

Worked solution
A4n = 8B7n = 10C4n = 5P = 0.25
P(A|R)=rA/nArA/nA+rB/nB+rC/nC
  1. Red from each box: 4/8 = 0.5, 7/10 = 0.7, 4/5 = 0.8
  2. Together: 0.5 + 0.7 + 0.8 = 2
  3. Box A given red: 0.5/2 = 0.25

Answer: 0.25

Example 3 · level 9

A disease affects 4% of the people in a country. A test for it is positive for 91% of the people who have the disease, and also for 10% of the people who do not. A person tests positive. What is the probability, as a percentage to one decimal place, that this person has the disease?

4 %ill91 %+9 %−96 %healthy10 %+90 %−P = ?
Hint

Two kinds of people test positive: the ill ones the test finds, and the healthy ones it wrongly flags.

Worked solution
4 %ill91 %+9 %−96 %healthy10 %+90 %−P ≈ 27.5 %
P(I|+)=P(I)P(+|I)P(I)P(+|I)+P(I')P(+|I')
  1. Ill and positive: 0.04 × 0.91 = 0.0364
  2. Healthy and positive: 0.96 × 0.1 = 0.096
  3. Ill given positive: 100 × 0.0364/(0.0364 + 0.096) ≈ 27.5%

Answer: 27.5%

Example 4 · level 9

Of the emails that reach an inbox, a share of 0.15 is spam. The word "prize" appears in spam with probability 0.34, and in other emails with probability 0.09. An email contains the word "prize". What is the probability that it is spam?

0.15spam0.34word0.66no wordother0.09word0.91no wordP = ?
Hint

Find how often the word appears at all; spam with the word is one part of it.

Worked solution
0.15spam0.34word0.66no word= 0.85other0.09word0.91no wordP = 0.4
P(S|W)=P(S)P(W|S)P(S)P(W|S)+P(S')P(W|S')
  1. Spam with the word: 0.15 × 0.34 = 0.051
  2. Other email with the word: 0.85 × 0.09 = 0.0765
  3. Spam given the word: 0.051/(0.051 + 0.0765) = 0.051/0.1275 = 0.4

Answer: 0.4

Example 5 · level 9

In a city, 13% of the taxis are green and the rest are blue. A witness to an accident says the taxi was green. Tested in the same light, the witness names the colour of a taxi correctly 87% of the time. What is the probability that the taxi was green?

13 %green87 %says green13 %says bluebluesays green87 %says blueP = ?
Hint

The witness says green for green taxis named right and for blue taxis named wrong.

Worked solution
13 %green87 %says green13 %says blue= 87 %blue= 13 %says green87 %says blueP = 0.5
P(G|g)=P(G)P(g|G)P(G)P(g|G)+P(B)P(g|B)
  1. Green and said green: 13% × 87% = 0.1131
  2. Blue and said green: 87% × 13% = 0.1131
  3. Green given said green: 0.1131/(0.1131 + 0.1131) = 0.1131/0.2262 = 0.5

Answer: 0.5

Example 6 · level 10

A box holds 7 fair dice and 2 loaded ones; a loaded die shows a six with probability 0.3. A die is taken at random and rolled twice, and it shows a six both times. What is the probability, as a percentage to one decimal place, that the die is loaded?

2loaded0.3six, six7fair1/36six, sixP = ?
Hint

Weigh each kind of die by how many there are and by its chance of two sixes; a fair die gives two sixes once in 36.

Worked solution
2loaded0.3six, six7fair1/36six, sixP ≈ 48.1 %
P(L|66)=lx2lx2+f/36
  1. Loaded and two sixes, as a weight: 2 × 0.3² = 2 × 0.09 = 0.18
  2. Fair and two sixes: 7/36
  3. Loaded given two sixes: 100 × 0.18/(0.18 + 7/36) ≈ 48.1%

Answer: 48.1%

Example 7 · level 10

A disease affects 7% of the people who come to a clinic. A test for it is positive for 95% of the people who have the disease, and also for 10% of the people who do not. A patient tests negative. What is the probability, as a percentage to one decimal place, that this patient has the disease after all?

7 %ill95 %+5 %−93 %healthy10 %+90 %−P = ?
Hint

A negative result comes from the ill people the test misses and from the healthy people it clears.

Worked solution
7 %ill95 %+5 %−93 %healthy10 %+90 %−P ≈ 0.4 %
P(I|−)=P(I)P(−|I)P(I)P(−|I)+P(I')P(−|I')
  1. Ill and negative: 0.07 × 0.05 = 0.0035
  2. Healthy and negative: 0.93 × 0.9 = 0.837
  3. Ill given negative: 100 × 0.0035/(0.0035 + 0.837) ≈ 0.4%

Answer: 0.4%

Example 8 · level 10

A bag holds 12 fair coins and 2 coins with heads on both sides. A coin is taken at random and tossed 2 times; it lands heads every time. What is the probability that it is a two-headed coin?

212heads × 2P = ?
Hint

A fair coin gives all heads with probability one half to the power of the number of tosses; a two-headed coin always does. Weigh each by how many coins there are.

Worked solution
212heads × 2P = 0.4
P(D|Hk)=tt+f/2k
  1. All heads, as a weight: 2 × 1 for two-headed coins and 12 × 1/4 for fair ones
  2. Times 4: 2 × 4 = 8 against 12
  3. 8/(8 + 12) = 8/20 = 0.4

Answer: 0.4

Example 9 · level 10

A disease affects 6% of the people in a country. A test for it is positive for 98% of the people who have the disease, and also for 4% of the people who do not. A person tests positive, and a second test, independent of the first, is positive too. What is the probability, as a percentage to one decimal place, that this person has the disease?

6 %ill98 %+98 %+94 %healthy4 %+4 %+P = ?
Hint

For two independent positives, multiply each kind of person's chance of a positive twice.

Worked solution
6 %ill98 %+98 %+94 %healthy4 %+4 %+P ≈ 97.5 %
P(I|++)=P(I)s2P(I)s2+P(I')f2
  1. Ill and two positives: 0.06 × 0.98 × 0.98 = 0.057624
  2. Healthy and two positives: 0.94 × 0.04 × 0.04 = 0.001504
  3. Ill given two positives: 100 × 0.057624/(0.057624 + 0.001504) ≈ 97.5%

Answer: 97.5%

Ready for the quiz?

Check yourself on this step: 5 questions, 8 minutes.

Start the quiz

All steps of the Probability study guide

  1. Dice and coins

    Totals of two dice, numbers of heads, all different, and chances given what you already know.

  2. Tables and Venn diagrams

    Read P(A given B) from a table, fill in a missing cell, and use Venn diagrams with two or three sets.

  3. Tree diagrams and draws

    Two draws from a bag, rain on two days, faulty items from two machines, and reverse questions.

  4. Independent events and repeated trials

    At least one fails, exactly k successes, the first success on try n, and how many tries are needed.

  5. Bayes and medical tests

    The chance someone is ill after a positive test, false positives, spam filters and unreliable witnesses.

  6. Expected value

    The expected profit of a raffle, a fair price for a game, winnings and insurance premiums.

When every step feels easy, take the whole Probability test: 10 questions in 15 minutes.