Reversing a Tree: the Base-Rate Answer

Ill-and-positive over every positive.

The tree in the order things happen

1 person in 1000 has an illness, and a test for it is right 99 times in 100. Draw the tree in the order things happen. First a person is ill, with probability 0.001, or well, with probability 0.999. Then the test says positive or negative: for an ill person, positive 0.99 and negative 0.01; for a well person, positive 0.01 and negative 0.99.

Multiply along each path. Ill and positive is 0.001 × 0.99 = 0.00099. Ill and negative is 0.001 × 0.01 = 0.00001. Well and positive is 0.999 × 0.01 = 0.00999. Well and negative is 0.999 × 0.99 = 0.98901. The four paths add to 0.00099 + 0.00001 + 0.00999 + 0.98901 = 1, because every person ends on exactly one of them.

0.001I0.99+0.000990.01−0.000010.999W0.01+0.009990.99−0.98901

I for ill and W for well, then + for a positive test and − for a negative one. Each path ends on the product of its branches. The colored path is ill and positive, 0.00099.

Two paths end in a positive

The test says positive. Two paths end there: ill and correctly caught, 0.00099, or well and misread, 0.00999. Only one of them can happen to a person, so add them. The chance of a positive test is 0.00099 + 0.00999 = 0.01098, about 11 people in a thousand.

Read the tree backwards

Given that the test said positive, the two negative paths are ruled out, and only the two positive paths are left. They make up 0.01098 between them, and that is the new whole. The ill path is 0.00099 of it.

So the chance of being ill, given a positive test, is the ill path divided by all the positive paths: 0.00099 ÷ 0.01098, which is about 0.090. In the notation for conditional probability, P(ill | positive) = P(ill and positive) / P(positive).

Most of the 0.01098 comes from the well path, 0.00999 against 0.00099, about 10 to 1. The well path is a small branch, 0.01, on a very large one, 0.999.

The tree turned round

The same four paths can be drawn with the test result first. The first branches are then positive, 0.01098, and negative, 1 − 0.01098 = 0.98902. After a positive, the branch to ill is 0.00099 ÷ 0.01098 ≈ 0.090 and the branch to well is 0.00999 ÷ 0.01098 ≈ 0.910. After a negative, the branch to ill is 0.00001 ÷ 0.98902, about 0.00001, and the branch to well is about 0.99999.

Multiplying along this tree gives the same four paths: 0.01098 × 0.090 ≈ 0.00099 for positive and ill. Reversing a tree means finding these new branches by dividing each path by the total of the branch it now sits on.

0.011+0.090I0.000990.910W0.009990.989−
I0.00001
W0.98901

The same people with the test result first: + for positive and − for negative, then I for ill and W for well, with the branches rounded. The colored branch after the positive, 0.090, is the chance of being ill given a positive test. After a negative, the branches are about 0.00001 and 0.99999.

Check by counting

Take 100,000 people. 100 are ill, and 99 of them test positive. 99,900 are well, and 1 in 100 of them, 999, test positive. So 99 + 999 = 1,098 people test positive, and 99 of them are ill: 99/1098 ≈ 0.090, the same answer.

Rounded, that is about 1 positive in 11 who is really ill. A positive result from a test that is right 99 times in 100 means ill only about 9 times in 100.

positives

About 11 positives for each person who is ill and tests positive. The shaded part is the 1 who is ill.

A negative result

The same reading works for a negative. Given a negative test, the whole is the two negative paths, 0.00001 + 0.98901 = 0.98902, and the chance of being well is 0.98901 ÷ 0.98902, about 0.99999. With an illness this rare, a negative result is very reliable, while a positive one is not.

Bayes' theorem

The ill path is 0.001 × 0.99: the chance of being ill, P(ill), times the chance of a positive given ill, P(positive | ill). Putting that on top of the division gives Bayes' theorem: P(ill | positive) = P(ill) × P(positive | ill) / P(positive).

It turns a chance that the tree gives, positive given ill, into the reverse chance, ill given positive. The bottom, P(positive), is always the sum of every path that ends in a positive.

A weather forecast

In a town it rains on 1 day in 5. On days when it rains, the forecast says rain 9 times in 10. On dry days, it says rain 1 time in 10. The forecast says rain. What is the chance that it rains?

Rain and a forecast of rain is 0.2 × 0.9 = 0.18. Dry and a forecast of rain is 0.8 × 0.1 = 0.08. The forecast says rain on 0.18 + 0.08 = 0.26 of days. So the chance of rain, given a forecast of rain, is 0.18 ÷ 0.26 = 9/13, about 0.69.

The usual mistakes

Answering 0.99. That is the branch for a positive given ill, read forwards. The question gives the positive and asks about the illness.

Putting the wrong path on top. The numerator is the path you want, ill and positive, 0.001 × 0.99. The product 0.999 × 0.01 is the well path, which belongs only in the bottom, and 0.001 × 0.01 is ill and negative, which is not a positive at all.

Leaving a path out of the bottom. The bottom is every path that ends in a positive, ill and well, 0.01098. Dividing by the well path alone, or forgetting to divide, gives the wrong whole.

Thinking the two positive paths are about even, so the answer is about a half. The well path is ten times the ill path, because the well outnumber the ill a thousand to one.

Faulty bolts

In the application below, a bolt is made by one of two machines and may be faulty. Part (a) adds the two paths that end in a faulty bolt; part (b) reads the tree backwards to find the chance that a faulty bolt came from machine B.

Worked example: A Faulty Bolt Traced Back to the Machine That Made It, by Reversing a Tree

Question A factory makes bolts on two machines. Machine A makes 35 of the bolts and machine B makes the rest. 120 of the bolts from machine A are faulty, and 110 of the bolts from machine B. An inspector picks a bolt at random. (a) Find the probability that it is faulty. (b) The bolt turns out to be faulty. Find the probability that it was made by machine B.

  1. 1.The first branches are machine A, 35, and machine B, 25. After A the bolt is faulty with probability 120 and good with 1920. After B it is faulty with probability 110 and good with 910.

    machine3/5A2/5Bbolt1/20faulty19/20good1/10faulty9/10goodfirst the machine, then the bolt
    machine3/5A2/5Bbolt1/20faulty19/20good1/10faulty9/10goodfirst the machine, then the bolt
    The tree follows the order of events: first the machine, then whether the bolt is faulty.
  2. 2.Multiply along each path: A and faulty 35 × 120 = 3100, A and good 57100, B and faulty 25 × 110 = 4100, and B and good 36100. Check: 3 + 57 + 4 + 36 = 100.

    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/1003/5 × 1/20 = 3/100, and so on3 + 57 + 4 + 36 = 100
    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/1003/5 × 1/20 = 3/100, and so on3 + 57 + 4 + 36 = 100
    Multiply along each path. The four paths add up to 100100 = 1.
  3. 3.(a) Two paths end in a faulty bolt, so P(faulty) = 3100 + 4100 = 7100.

    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/100faulty: 3/100 + 4/100 = 7/100
    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/100faulty: 3/100 + 4/100 = 7/100
    (a) Two paths end in a faulty bolt: 3100 + 4100 = 7100.
  4. 4.Reverse the tree. Given that the bolt is faulty, only those two paths are possible, and the path through B is 4100 of the 7100: P(B | faulty) = 4100 ÷ 7100.

    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/100given faulty: the path through Bis 4 of the 7 hundredths
    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/100given faulty: the path through Bis 4 of the 7 hundredths
    Given a faulty bolt, only those two paths are possible, and the path through B is 4100 of the 7100.
  5. 5.(b) P(B | faulty) = 47. Machine B makes fewer of the bolts but more than half of the faulty ones. Check with 1000 bolts: A makes 600 with 30 faulty, B makes 400 with 40 faulty, and 4070 = 47.

    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/100B given faulty: 4/71000 bolts: 30 faulty from A, 40 from B
    machine3/5A2/5Bbolt1/20faulty3/10019/20good57/1001/10faulty4/1009/10good36/100B given faulty: 4/71000 bolts: 30 faulty from A, 40 from B
    (b) P(B | faulty) = 47, and 4070 = 47 with 1000 bolts.

Answer: (a) 7100; (b) 47

Common mistakes

  • Answering (b) with 110, the chance that a bolt from machine B is faulty. The question asks the reverse: given a faulty bolt, how likely it is to have come from B. The whole is the faulty bolts, 7100 of all the bolts.
  • Answering (b) with 25, the share of the bolts that machine B makes, as if knowing the bolt is faulty changed nothing. Machine B makes faulty bolts twice as often as machine A, so a faulty bolt is more likely than a random bolt to have come from B.

More probability with several events problems, worked step by step →

Practice Reversing a Tree: the Base-Rate Answer in the app