sciandu
Mathematics

Mathematics

Bayes' theorem

A test is 99% reliable and yet a positive result is usually wrong. How that can be.

A test for a rare disease detects 99% of all people who have it. In healthy people it wrongly triggers in only 1% of cases. Your test is positive. How likely is it that you are ill? Most people answer 99%. The correct answer is often below 10%, and this difference is not a quibble, it has real consequences in medicine and in the courts.

The direction is what matters

The test promises: if you are ill, then the test is probably positive. That is P(positiveill)P(\text{positive} \mid \text{ill}). But what you want to know is: if the test is positive, am I ill? That is P(illpositive)P(\text{ill} \mid \text{positive}). These two numbers look almost the same and are completely different, because they count inside different groups.

Bayes' theorem is the rule for getting from one direction to the other. You can write it as a formula, but you can also manage without: simply calculate with a large number of people and count. That route is less error-prone and easier to explain.

Calculating with 10,000 people

Suppose 1% of the population is ill. Among 10,000 people that is 100 ill and 9900 healthy. Of the 100 ill people the test detects 99. Of the 9900 healthy ones it wrongly triggers in 1% of cases, which is 99 people. So in total there are 99+99=19899 + 99 = 198 positive tests, and only half of them belong to people who are really ill.

P(krankpositiv)=9999+99=50%P(\text{krank} \mid \text{positiv}) = \frac{99}{99 + 99} = 50\,\%
Correct hits divided by all positive tests, including the wrong ones.

The reason for this surprising result is the size of the two groups. There are almost a hundred times as many healthy people as ill ones. So even a tiny error rate in a huge group produces just as many cases as a large hit rate in a small one. This starting is called the base rate, and ignoring it is the most common error of reasoning in probability.

Percent bar
Percent25%
Base value200
25%
0200
25% of 200 = 50
Set the base value to 400 and the percentage to 5. The bar shows 20, and exactly this ratio makes the problem visible: a small percentage of a large group gives a surprisingly large count. Push the percentage down to 1: 4 cases still remain. If the ill group itself is only 4 people, then false and correct hits are equally frequent.

When the disease is more common

Do the same calculation again with a disease affecting 10% of people. Out of 10,000 that means 1000 ill and 9000 healthy. The test finds 990 ill people and produces 90 false alarms. Now 990108092%\frac{990}{1080} \approx 92\,\% of the positive tests are correct. The same test, the same accuracy, an entirely different result.

That is exactly why the whole population is not tested for rare diseases, only people with symptoms or in a risk group. In that smaller group the base rate is much higher, and only then does a positive result carry weight. And that is why in practice a positive test is confirmed with a second, different method.

Exercises

0 of 6 solved

Time to try it yourself. You can't break anything, every attempt counts.

What does P(illpositive)P(\text{ill} \mid \text{positive}) describe?

In a town of 10,000 inhabitants, 2% are ill. How many people is that?

Of 9800 healthy people a test wrongly triggers in 1% of cases. How many false alarms is that?

The frequency of a disease in the population is called the .

Among 200 ill people the test detects 196, and among the healthy there are 98 false alarms. How likely is illness given a positive test?

Put the steps of a Bayes calculation into the right order.

  1. 1Split them into ill and healthy using the base rate.
  2. 2Work out the false alarms among the healthy.
  3. 3Work out the correct hits among the ill.
  4. 4Choose a large round number of people, say 10,000.
  5. 5Divide the correct hits by all the positive tests together.