Bayes' Theorem
Often the probability you know runs the “wrong way”. A factory knows how often each machine makes a faulty item, but when a customer returns a faulty item, the question is which machine probably made it. A doctor knows how accurate a test is for people who have a disease, but the patient wants to know the chance they have the disease given a positive result. Bayes’ theorem turns into . It’s one formula, but it changes how you think about evidence.
Key ideas
Section titled “Key ideas”Reversing a conditional probability
Section titled “Reversing a conditional probability”From the definition of conditional probability, and also . Setting these equal and dividing by :
That’s the heart of Bayes’ theorem: to reverse the condition, you need the “forward” probability and the overall probability .
Two events
Section titled “Two events”Usually isn’t given directly. Event either happens or it doesn’t, so can happen in two ways, and
Putting this in the denominator gives Bayes’ theorem:
Three events
Section titled “Three events”If exactly one of , , must happen (they’re mutually exclusive and their probabilities add to ), the same idea gives
The IB course uses Bayes’ theorem for at most three events like this.
Tree diagrams make it automatic
Section titled “Tree diagrams make it automatic”You don’t have to memorize the formula if you can draw the tree:
- First branches: the possible causes ( and , or , , ), with their probabilities.
- Second branches: whether happens, with the conditional probabilities .
- Multiply along each path that ends in . Their sum is (the denominator).
- is the path through divided by that sum.
In words:
Prior and updated probabilities
Section titled “Prior and updated probabilities”is sometimes called the prior probability (before you know about ), and the updated (posterior) probability. If new evidence arrives, the updated probability can become the prior for the next step. This only works if the pieces of evidence are independent of each other once you know whether happened.
Worked examples
Section titled “Worked examples”Example 1: Two events
Section titled “Example 1: Two events”On any school day, the probability of rain is . If it rains, the probability that Maya is late is ; if it doesn’t rain, it’s . Given that Maya is late, find the probability that it was raining.
Solution. Let = rain and = late. The two paths that end in “late”:
So and
Knowing Maya is late raises the probability of rain from to about .
Example 2: Three machines
Section titled “Example 2: Three machines”A factory has three machines. Machine A makes of the items, machine B makes and machine C makes . The proportions of defective items are for A, for B and for C. An item is chosen at random and is defective. Find the probability that it was made by each machine.
Solution. Let = defective. From the tree:
Then divide each path by :
Check: . ✓
Machine C makes only of the items, but it’s just as likely as machine A to be the source of a defective one, because its defect rate is so much higher.
Example 3: A second test
Section titled “Example 3: A second test”A disease affects of a population. A test gives a positive result for of people who have the disease and for of people who don’t.
- (a) A person tests positive. Find the probability that they have the disease.
- (b) The person takes the test again and again tests positive. Assuming the two results are independent given whether the person has the disease, find the new probability that they have the disease.
Solution.
(a) Let = has the disease and = positive.
Only about : most positives come from the large healthy group.
(b) Now the prior is (keep it unrounded):
A second positive result raises the probability from about to about . That’s why positive screening results are confirmed with a repeat test.
Example 4: Coins tossed twice
Section titled “Example 4: Coins tossed twice”A jar holds five coins: two fair coins, one coin with heads on both sides, and two biased coins that each land heads with probability . A coin is chosen at random and tossed twice, and it lands heads both times. Find the probability that it was the two-headed coin.
Solution. The priors are , and . The two tosses are independent, so for each type of coin you square its chance of heads:
Add the three paths that end in two heads:
Check: before the tosses the two-headed coin had a chance; two heads in a row raise that to , which makes sense because the other coins rarely give two heads.
Common mistakes
Section titled “Common mistakes”Mixing up and . ” of people with the disease test positive” is . It does not mean that of positive results have the disease; Example 3 shows that’s only about . Write each given probability in notation before you start.
Forgetting a path in the denominator. is the sum of all the paths that end in . With three causes, there are three paths. Leaving one out makes the answer too big.
Using the wrong second-branch probability. On the “not defective” branches you need , and so on. If the question is about a negative test or a non-defective item, use those complementary branches in both the numerator and the denominator.
Ignoring the base rate. A very accurate test for a rare condition can still produce mostly false positives. The prior probability matters as much as the test accuracy.
Rounding the updated probability before reusing it. In Example 3(b), using instead of changes the answer to . Keep full accuracy until the end.
Practice
Section titled “Practice”1. (Warm-up) , and . Find .
Solution
2. (Warm-up) , and . Find .
Solution
. Then
3. (Core) A phone maker buys a part from three suppliers: from supplier 1, from supplier 2 and from supplier 3. The parts are faulty , and of the time. A part is found to be faulty.
- (a) Find the probability that it came from supplier 3.
- (b) Which supplier is it most likely to have come from?
Solution
(a) The faulty paths: , , . So .
(b) and (3 s.f.). Supplier 3 is the most likely source, even though it supplies the fewest parts.
4. (Core) of the emails a company receives are spam. A filter flags of spam emails and of genuine emails.
- (a) An email is flagged. Find the probability that it is spam.
- (b) An email is not flagged. Find the probability that it is spam.
Solution
(a) Flagged paths: spam ; genuine .
(b) Not-flagged paths: spam ; genuine .
5. (Core) Students at a school travel by bus (), by car () or on foot (). The probabilities of being late are by bus, by car and on foot. A student chosen at random arrived on time. Find the probability that they walked.
Solution
Use the “on time” branches: , and .
6. (Core) A fair six-sided die is rolled. If it shows or , a ball is taken from box A, which holds green and yellow balls. Otherwise, a ball is taken from box B, which holds green and yellow balls. Given that the ball is green, find the exact probability that it came from box A.
Solution
and . and .
7. (Core) For the factory in Example 2, an item is chosen at random and is not defective. Find the probability that it was made by machine C.
Solution
. The path through C is .
That’s slightly less than C’s share of , since C’s items are more likely to be defective.
8. (Challenge) A test for a condition gives a positive result for of people who have it and for of people who don’t. In a certain population, half of the people who test positive actually have the condition. Find the proportion of the population that has the condition.
Solution
Let . Then
of the population has the condition.
Check: . ✓
9. (Challenge) In a multiple-choice quiz, each question has options. A student knows the answer to a question with probability ; otherwise she guesses at random. If she knows the answer, she gets it right.
- (a) Show that the probability she knew the answer, given that she got it right, is .
- (b) Find this probability when .
- (c) Find if this probability is .
Solution
(a) Let = knows and = right. and .
(b) .
(c)
Homework
Section titled “Homework”Try these independently after the practice questions. Show your setup and explain your reasoning. Use exact answers where possible, and check that your answers fit the question. Homework solutions are not provided on the published site.
Describe your tree diagram in words or sketch it, and give decimal answers to 3 significant figures unless the question asks for an exact answer.
Foundations
Section titled “Foundations”H1. (Foundations) Without a calculator: , and .
- (a) Find .
- (b) Find .
- (c) Find the exact value of .
H2. (Foundations) In a hypothetical coastal town in Nova Scotia, it rains on of days. The local forecast predicts rain on of the days when it does rain, and on of the days when it stays dry.
- (a) The forecast predicts rain. Find the probability that it actually rains.
- (b) The forecast predicts no rain. Find the exact probability that it rains anyway.
H3. (Core) A hockey-stick company has three plants. Plant X makes of its sticks, plant Y makes and plant Z makes . The proportions of sticks with a defect are at X, at Y and at Z (hypothetical data). A stick is chosen at random.
- (a) Find the probability that the stick is defective.
- (b) The stick is defective. Find the exact probability that it came from each plant, and say which plant is the most likely source.
- (c) A different stick is chosen and it is not defective. Find the probability that it came from plant X.
H4. (Core) A screening test for a condition is used on a population in which of people have the condition. The test is positive for of people who have it and for of people who don’t.
- (a) Find the probability that a person who tests positive has the condition.
- (b) Find the probability that a person who tests negative has the condition.
- (c) Imagine people are tested. How many would you expect to have the condition and test positive? How many would you expect to be healthy but test positive? Use these counts to check your answer to (a).
H5. (Core) A trail camera in Algonquin Park is set off either by an animal or by wind moving the branches. Its software labels a photo “animal” for of the photos set off by animals and for of the photos set off by wind. Over a season, of the photos labelled “animal” really did show an animal. Let be the proportion of photos that were set off by animals. Find .
H6. (Core) (IB style) Do not use a calculator. A spinner chooses box 1 with probability , box 2 with probability and box 3 with probability . Box 1 holds red and blue marbles, box 2 holds red and blue, and box 3 holds red and blue. One marble is taken at random from the chosen box.
- (a) Show that the probability the marble is red is .
- (b) Given that the marble is red, find the probability that it came from box 3.
- (c) Given that the marble is red, find the probability that it did not come from box 1.
Challenge
Section titled “Challenge”H7. (Challenge) A rare condition affects person in . A test for it is positive for of people who have the condition, and negative for of people who don’t.
- (a) Find the probability that a person who tests positive has the condition.
- (b) Many people are surprised that a ” accurate” test gives such a low answer. Explain, in two or three sentences, why a positive result can still mean a low probability of having the condition. Use expected counts for people in your explanation.
- (c) Keep the same test. What proportion of the population would need to have the condition for a positive result to mean a chance of having it?
H8. (Challenge) A bag scanner flags of bags that contain a prohibited item. It also flags of bags that don’t. Suppose of bags contain a prohibited item (hypothetical data). Jordan writes:
“The scanner catches of prohibited items, so if a bag is flagged, there’s a chance it contains a prohibited item.”
- (a) Write the probability in notation, and write the probability Jordan is really talking about in the same notation.
- (b) Explain Jordan’s mistake.
- (c) Find the correct probability that a flagged bag contains a prohibited item.
H9. (Challenge) Do not use a calculator. A box holds three dice that look the same: a standard die, a die with three faces showing (and three faces showing ), and a die with no at all. One die is chosen at random and rolled.
- (a) The die shows . Find the probability that it is the die with three sixes.
- (b) The same die is rolled again (the rolls are independent) and shows again. Find the probability that it is the standard die, given both results.
- (c) Check your answer to (b) a second way: use your answers to (a) as the new prior probabilities and update them with the second roll. Explain why the die with no drops out of the calculation completely.
H10. (Challenge) Let , and let and , where and are not both .
- (a) Prove that if and only if . In words: evidence makes more likely exactly when is more likely to happen with than without it.
- (b) A poorly designed test is positive for of people with a condition and for of people without it. In a group where have the condition, find the exact probability that a person who tests positive has it, and explain how your answer fits part (a).