ViewWiki

Lesson 4 of 4

Bayes' theorem.

About 25 minutes · 5 practice questions

From counting in the hall to a formula: Bayes' theorem turns the condition round, a retest beats the base rate, what comes out after one piece of evidence is the starting point for the next, and the prosecutor's fallacy.

Step 1 of 5 · The formula

Step 1 of 5

The formula

So far we have counted people. The same sum can be written in chances. Write DD⁠ for “ill”, HH⁠ for “healthy” and ++⁠ for “a positive result”. The question of someone who tested positive is P(D∣+)P(D \mid +)⁠: how many of the positives are ill. The numerator is the left-hand mat, the ill positives, and the denominator is both mats together:

P(D∣+)=P(+∣D)⋅P(D)P(+∣D)⋅P(D)+P(+∣H)⋅P(H)P(D \mid +) = \frac{P(+ \mid D) \cdot P(D)}{P(+ \mid D) \cdot P(D) + P(+ \mid H) \cdot P(H)}⁠

This is Bayes’ theorem. P(D)P(D)⁠ is the base rate, P(+∣D)P(+ \mid D)⁠ and P(+∣H)P(+ \mid H)⁠ are what you know about the test, and what comes out, P(D∣+)P(D \mid +)⁠, is what you want to know.

Here 2%2\%⁠ are ill and the test is 95%95\%⁠ accurate. Work it out, then sort the positives and check.

To the question

Step 2 of 5

Turning the condition round

The denominator in the formula is simply P(+)P(+)⁠, all the positives, as you saw on the trees. So the theorem can be written more briefly too. Its power is that it turns the condition round: from the chance of a positive test given the disease, which a lab measures, to the chance of the disease given a positive test, which the patient needs.

To the question

Step 3 of 5

Testing again

28%28\%⁠ is still not much. What can you do? Retest the positives is on: everyone who tested positive is tested again, independently, and stays positive only if the second test agrees. Work out the chance now.

To the question

Step 4 of 5

One step at a time

The mats show what the sum said: almost all the healthy were weeded out by the second test. There is another way to see it. After the first test, the chance of being ill is no longer 2%2\%⁠ but 27.9%27.9\%⁠. That number can go into the formula as a new base rate.

To the question

Step 5 of 5

The prosecutor’s fallacy

The same mistake of turning the condition round turns up in courts too. The chance that a piece of evidence shows up for an innocent person is one thing; the judge needs the reverse, the chance the person is innocent given the evidence.

To the question

Still of the Bayesian reasoning and evidence 3D scene
Interactive scene

Loading the interactive version…

Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.

To the experiment

Practice · Calculate

2%2\%⁠ ill, and a 95%95\%⁠ accurate test. By Bayes’ theorem, what is the chance a positive is ill? Give it as a per cent, the number only, to one decimal place.

To the experiment

Practice · Choose

Write DD⁠ for the event “ill”, HH⁠ for “healthy” and ++⁠ for “a positive result”.

Which expression equals P(D∣+)P(D \mid +)⁠?

To the experiment

Practice · Calculate

Still 2%2\%⁠ ill and a 95%95\%⁠ test, but now everyone who tested positive is tested again, independently, and stays positive only if that test agrees. What is the chance a double positive is ill? Give it as a per cent, the number only.

To the experiment

Practice · Calculate

Another way to work out the second test: after the first positive, the chance of being ill is 27.9%27.9\%⁠. Use that as the new base rate, and apply Bayes again with the 95%95\%⁠ test. What comes out? Give it as a per cent, the number only.

To the experiment

Practice · Choose

DNA is found at a crime scene. The chance an innocent person matches it by chance is 11⁠ in 10,00010{,}000⁠. The city has 500,000500{,}000⁠ people, and one suspect who matches is found, with no other evidence. The prosecutor says: “The chance he is innocent is 11⁠ in 10,00010{,}000⁠”. What is right?