This whole subtopic is higher level. Nothing in it is on an SL paper.
Educerie · IB Diploma · Mathematics: analysis and approaches
IB Mathematics AA 4.13 · HL only
Bayes' theorem
When you know how likely the evidence is for each possible cause, how do you work out how likely each cause is, now that you have seen the evidence?
What you will learn
- HL Understand that Bayes' theorem turns P(evidence | cause) into P(cause | evidence)
- HL Know Bayes' theorem for two causes and for three causes that split the sample space
- HL Understand why a positive result for a rare condition can still mean a low chance of having it
- HL Know that when the evidence is equally likely under every cause, the probability of the cause does not change
You must be able to
- HL Calculate a reversed conditional probability with Bayes' theorem from a tree or from given probabilities
- HL Calculate the total probability of the evidence as a sum of products
- HL Solve Bayes' problems with three causes and check the answers add to 1
- HL Comment on what a screening test result means in context
- HL Solve for an unknown probability from a given Bayes' answer
- HL Show that equal likelihoods under each cause mean the events are independent
In the exam. HL Paper 1 and Paper 2, as a 3 to 6 mark part of a longer probability question, usually after a tree diagram: "given that the parcel was damaged, find the probability that it passed through the south centre". Paper 1 uses exact fractions; Paper 2 uses decimals and contexts such as screening tests. A Paper 3 problem may hide a parameter that you find by working backwards.
1From the definition to the theorem
Start from the definition of conditional probability, aimed the way you want to go:
Now replace the top and bottom with things you know. The top comes from the alternate form in 4.11: .
The bottom is the total probability of . happens either with or with , and those two routes cannot overlap. So
Put both into the definition:
· Bayes' theorem, from the formula booklet.
The pair and is a partition of the sample space: they cannot both happen, and one must. The denominator needs only that.
Figure 1 shows where each piece sits on a tree. With drawn first, every quantity on the right-hand side of the formula is on a branch.
- The numerator is the product along the teal path, then .
- The denominator is the sum of the two paths that end in , teal and amber.
Bayes' theorem is nothing more than the "path over paths" recipe you used in 4.11, written in symbols.
Two small points:
- Sometimes a question gives outright instead of the two paths. Use the first form, , and there is nothing to add up.
- Once you have , the complement follows: . Given , either or happened.
You can quote the formula and substitute, or draw the tree and compute path over paths. Both are valid. The formula suits a question that gives conditional probabilities in words. The tree suits one that asks several things about the same situation.
2Your first reversals
Three small cases first, before the screening test.
Two sources, one flaw
- Example: a fruit stall buys crates from two farms, 60% from the hill farm () and 40% from the river farm (). An apple is bruised () with probability if from and if from .
- A randomly chosen apple is bruised. Which farm did it most likely come from? Draw the farm first, the bruise second.
Before the bruise, was the likelier source (). After it, is (), because bruises its apples twice as often. The evidence moved the probability from one farm to the other.
Reversing two draws
- The cause does not have to be a machine. It can simply be the first of two events.
- Example: a drawer holds 6 red and 4 black socks. Two are taken without replacement. Given that the second is black, find the probability that the first was red. In time order, the first draw is the cause and the second the evidence.
The second-draw fractions, after a red and after a black, change with the first draw. They are conditional: the draws are not independent.
Notice that equals . With no information about the first draw, the second is as likely to be black as the first. That is a useful check.
It is also a cue: when a question says "given that the second… find the probability that the first…", it is a Bayes question.
Reading it off a table. Counts make the idea visible. Example: a library recorded 500 loans.
| Overdue | Returned on time | Total | |
|---|---|---|---|
| Fiction | 45 | 255 | 300 |
| Non-fiction | 50 | 150 | 200 |
| Total | 95 | 405 | 500 |
Given that a loan is overdue, the chance it is fiction is . Restrict attention to the overdue column and take the fiction share.
In probability language this is , the formula with the 300s cancelling. If a question hands you a table, read the answer straight off. If it hands you percentages, you need the formula.
3A screening test
The guide names medical studies as the context. A screening test is used for a condition that affects 1% of the people screened.
- Among people who have the condition, the test is positive 95% of the time.
- Among people who do not, it is still positive 8% of the time (a false positive).
A person tests positive. How likely is it that they have the condition?
Let be "has the condition" and be "tests positive". Then , and .
A positive result means about an 11% chance of having the condition. Most people find that shocking: a "95% accurate" test sounds as though a positive should mean 95%.
Figure 2 shows why it does not, using natural frequencies. Imagine 10 000 people.
- About 100 have the condition, and 95 of them test positive.
- Of the 9 900 without it, 8% is 792, and every one of those tests positive too.
- So 887 people test positive, and only 95 of them have the condition.
The false positives swamp the true ones, because there are so many more healthy people for the 8% to act on.
The 1% is the prior probability, before any evidence. The answer is the posterior probability, after it. You need not use the words, but they tell the story.
The evidence raised the probability more than tenfold, from to . It is still far from certain, because the prior was so small.
Figure 3 plots the same test in groups where the condition is more or less common. The posterior rises steeply with the prior. Where 30% have the condition, a positive result means .
The test did not change; the people did. That is why screening programmes aim tests at high-risk groups, and why a positive screening result is usually followed by a second, different test.
A negative result is a different question. uses the paths that end in a negative:
A negative result is very reassuring: about 5 or 6 people in 10 000. Questions often ask for both, then ask you to comment.
A good comment names both numbers: "the test is good at ruling the condition out, since is tiny, but poor at ruling it in, since is only ."
4Updating twice: a second positive test
Suppose the person who tested positive takes the same test again and is positive again. The starting point is now , not 1%: what you know after the first test. Apply the theorem again with that as the prior.
The question will state the assumption: the two results are independent for a person of known status.
Figure 4 shows the three stages. One positive raised to . A second raised it to .
You get the same in one step by treating "positive twice" as the evidence. Then and , so . Two routes, one answer: a good check.
5Bayes' theorem with three events
The guide asks for Bayes' theorem "for a maximum of three events". The possible causes are split into three: , and .
- They are mutually exclusive: only one can happen.
- They are exhaustive: one of them must happen. So .
The theorem keeps its shape: one path on top, every path to underneath.
The denominator comes from the same argument as before. , and partition the sample space, so can only happen together with exactly one of them:
Putting this under gives the theorem:
for · from the formula booklet.
Example: a courier company sorts parcels at three centres. 45% go through the north centre (), 35% through central () and 20% through south (). The probability that a parcel is damaged () is at , at and at .
A customer receives a damaged parcel. Which centre most probably handled it? Figure 5 draws the tree with the three products.
Central is the most probable source (), even though south has the worst damage rate. South handles too few parcels, and north's low damage rate keeps its share down despite its traffic.
Bayes' theorem weighs both at once: how common each cause is, and how likely each is to produce the evidence.
Always check that the posteriors add to 1. Given the evidence, exactly one cause happened. The check takes ten seconds and catches a wrong denominator.
Conditioning on the complement
- "Given that a parcel arrived undamaged, find the probability that it went through the north centre" uses the branches. , and (3 s.f.).
- An undamaged parcel is slightly more likely than average to have come through ( against ), because rarely damages anything.
6Paper 1 fractions and Paper 2 normal models
No calculator
- Numbers are chosen so that fractions work, but only if you organise them.
- Example: Ravi travels to the climbing hall by tram with probability , by bike with probability and on foot with probability . He arrives late with probability by tram, by bike and on foot. Tonight he is late. Find the probability that he cycled.
The other two are and . With for the bike they sum to 1.
Put the three products over a common denominator before you add. Dividing by a sum of unlike fractions is where Paper 1 answers go wrong. Walking is the likeliest explanation of lateness, though Ravi cycles twice as often as he walks.
Likelihoods from a normal model
- Sometimes is not given but must be found from a distribution.
- Example: a packing line has two machines. Machine 1 fills 55% of the jars, with masses normal, mean 250 g, standard deviation 3 g. Machine 2 fills the rest: normal, mean 256 g, standard deviation 3 g.
- A jar weighs less than 250 g. Find the probability that machine 1 filled it.
- Let be "mass under 250 g".
- For machine 1, 250 is the mean, so .
- For machine 2, 250 is two standard deviations below the mean, so .
On Paper 1 the normal facts are handed to you (a value at the mean gives , or a probability is quoted). On Paper 2 you find each likelihood on the calculator. Either way they feed the tree, and Bayes' theorem reads it backwards.
7When the evidence tells you nothing, and working backwards
The guide links this subtopic to independent events. Suppose the evidence is equally likely whatever the cause: . Then
The posterior equals the prior. Seeing does not change the probability of at all. That is exactly the definition of independence from 4.11, .
A test that is positive 20% of the time whether or not you have the condition is useless, and Bayes' theorem says so. The further apart and are, the more the evidence moves the probability.
Working backwards
- Because the theorem is an equation, a question can give the posterior and hide something else.
- Example: a factory sensor raises an alarm for 90% of real faults. Faults occur in 20% of the machines monitored. For a machine with no fault, the alarm sounds with probability . Given an alarm, the probability of a real fault is . Find .
Check by substituting back: .
When the condition is an inequality, the answer is a bound. For the screening test of section 3, a positive result means at least a 50% chance of the condition only if
The false-positive rate would have to fall from 8% to under about 0.96%. For a rare condition, one positive means little unless the false-positive rate is very low.
Practice questions
10 questions on this note, from easy to hard. Each one you get right lights a star of this topic's constellation.