Use the law of total probability and Bayes' theorem for two or three events to reverse conditional probabilities, and interpret medical test results through sensitivity, specificity and the base rate.
Each is in the Maths AA glossary, with every other term in the subject.
A formula that reverses a conditional probability:
With a free account, Augment remembers where you stopped and what you have practiced.
Events that together cover the whole sample space, so at least one of them must occur. Mutually exclusive, exhaustive events form a partition of .
A positive test result for someone who does not have the condition. A false negative is a negative result for someone who does.
For mutually exclusive events that cover the sample space, , the sum over every path of a tree diagram that ends in .
The updated probability of an event after new evidence is taken into account, found with Bayes' theorem, such as .
The probability of an event before new evidence is taken into account, such as the proportion of a population that has a disease.
The probability that a test gives a positive result for someone who has the condition, .
The probability that a test gives a negative result for someone who does not have the condition, .
Evidence is usually observed in the opposite direction to the way the probabilities are known. A medical test is described by how often it is positive for people who have a disease, but a patient wants to know how likely it is that they have the disease, given that their test was positive. A factory knows the fault rate of each machine, but an inspector who finds a faulty item wants to know which machine probably made it. Bayes' theorem converts one kind of conditional probability into the other.
The theorem also describes how a probability should be updated when new evidence arrives: a prior probability, held before the evidence, is combined with the probability of the evidence to give a posterior probability. This idea is central to modern statistics, spam filtering and machine learning.
In 4.11, conditional probability was defined as
and a reverse conditional was found from a tree diagram by dividing one path by the sum of the paths that end in the given event. Bayes' theorem is this calculation written as a single formula. Before deriving it, the denominator, the probability of the observed event, needs a rule of its own.
A tree diagram whose first stage has two or three branches splits the sample space into pieces that cannot overlap and that leave nothing out. Such a collection of events is called a partition.
When form a partition, any other event is split into the three pieces

Each piece can be written with the multiplication rule,
On a tree diagram, the law of total probability is the familiar rule of adding the probabilities of every path that ends in .
The total probability is always between the smallest and largest of the conditional probabilities, here between and , because it is their average weighted by ,
The definition of conditional probability can be applied in either direction:
Substituting the second into the first gives
Finally, the law of total probability replaces in the denominator. This expresses entirely in terms of the probabilities on the branches of a tree drawn with first.
The structure of Bayes' theorem is easier to remember than the symbols: the numerator is the one path through the event wanted, and the denominator is the total of all the paths that end in the observed event .
YouTubeIn Bayes' theorem, is the probability of before the evidence is observed, and is its probability afterwards.
The prior probability is often called the base rate when it is the proportion of a population with some property. The posterior probability can be larger or smaller than the prior: evidence that is more likely under than under raises the probability of , and evidence that is less likely under lowers it.
With three possible causes, the denominator has three terms, one for each branch of the first stage. The posterior probabilities of the three causes always add up to , which is a useful check.
Bayes problems can also be set without a context, in terms of bags or dice that select another trial. The method is the same: draw the tree, find the total probability of the observed result, and divide.
Bayes' theorem is an equation linking the prior, the two conditional probabilities and the posterior. If the posterior is given, the equation can be solved for an unknown prior.
A diagnostic test gives a positive or a negative result, and the person tested either has the condition or does not. There are four possible combinations, two correct and two incorrect.
Test positive | Test negative | |
|---|---|---|
Has the condition | true positive | false negative |
Does not have the condition | false positive | true negative |
A test's accuracy is described by two conditional probabilities, measured in trials where the true status of every person is known.
The sensitivity and specificity are the probabilities on the second-stage branches of a tree drawn with "condition" first. A false positive occurs with probability for each healthy person tested, and a false negative with probability for each person with the condition. The proportion of the population with the condition, the prevalence, is the prior probability.
The question a patient asks is the reverse of the sensitivity: given a positive result, how likely is it that they have the condition? This is a Bayes' theorem calculation, and the answer depends strongly on the prevalence.
In November 2020 an evaluation of a rapid lateral flow test for COVID-19 reported a sensitivity of and a specificity of .
Source: University of Oxford and Public Health England, evaluation of the Innova SARS-CoV-2 lateral flow test, 11 November 2020.
Even with a specificity above , almost of positive results in this population are false positives. The reason is that of the people tested are not infected, so a small false positive rate applied to a very large group produces many false positives.
The same calculation is easier to understand with a large imaginary population. Out of people, (that is, ) are infected. The test is positive for of these and for of the

The positive results come from two groups: true positives and false positives. The proportion of positives that are true is
exactly the result of Bayes' theorem. Natural frequencies show directly why the false positives matter: there are fewer of them than true positives, but not by much.
The probability is not a fixed property of the test: it depends on the prevalence . For this test,
The graph shows this as a function of the prevalence.
When only of those tested are infected, a positive result means infection with probability only about : four out of five positives are false. This is the base-rate effect. A test used to screen a whole population, where the condition is rare, produces a much larger proportion of false positives than the same test used on people with symptoms, where the prevalence is higher. For this reason a positive screening result is usually followed by a second, more accurate test.
YouTubeA posterior probability can become the prior for the next piece of evidence. If a person who tested positive takes the test again, and the results are independent given the person's true status, Bayes' theorem is applied a second time with the new prior.
Bayes' theorem questions almost always involve a tree diagram, either given or to be drawn. Most marks are for setting up the right products and sums, so write the formula with letters first and then substitute.
The second question uses a partition into three events and is set without a calculator, so the numbers are chosen to simplify.
A Bayes calculation can be set out in three ways that always agree: as a tree with "path over total", with the formula from the booklet, or with natural frequencies. Choose the one that makes the question clearest, and use another as a check.
I can explain what a partition is and state the law of total probability for two or three events.
I can derive Bayes' theorem from the definition of conditional probability.
I can use Bayes' theorem for two events and for three events, and check that posterior probabilities add up to .
I can set out a Bayes problem as a tree diagram, with the formula, and with natural frequencies.
I can define sensitivity, specificity, false positive and false negative.
I can calculate the probability of a condition given a positive or negative test, and explain the base-rate effect.
I can use a posterior probability as a new prior when further evidence is observed.
I can solve for an unknown prior probability when a posterior probability is given.
18 exam-style questions on this subtopic, written in the style of the IB papers. The first has its markscheme open. Counted on
A café buys all of its coffee beans from three roasters, A, B and C. Of the bags of beans it buys, 45% come from roaster A, 35% from roaster B and 20% from roaster C.
The probability that a bag is stale when it is opened is 0.03 for roaster A, 0.05 for roaster B and 0.08 for roaster C.
A bag of beans is selected at random and opened.
Find the probability that the bag is stale.
2 marks
(M1)
A1
Given that the bag is stale, find the probability that it came from roaster C.
2 marks
(M1)
Given that the bag is not stale, find the probability that it came from roaster A.
2 marks
In a population, of people have a particular condition, . A screening test for gives a positive result for
Box X contains 3 red counters and 1 blue counter. Box Y contains 2 red counters and 3 blue counters. Box Z contains 1 red counter and 4 blue counters.
Pedro rolls a fair six-sided die. If he rolls a 1 he chooses box X, if he rolls a 2 or a 3 he chooses box Y, and otherwise he chooses box Z. He then takes one counter at random from the chosen box.
Find the probability that the counter is red.
3 marks
Given that the counter is red, find the probability that it was taken from box Y.
2 marks
One of 34 short multiple-choice questions on 4.13. Pick an answer to see why it's right or wrong.
It rains on 40% of days. A bus is late on 25% of rainy days and on 5% of dry days. Find the probability that the bus is late on a randomly chosen day.
The entries of the mathematics: analysis and approaches formula booklet that 4.13 uses. Each opens in the explained booklet.
If are mutually exclusive and exhaustive,
(a) Draw a tree diagram to represent this information.
(b) Find the probability that the item is defective.
(a) Let be "the item is defective". The first stage is the machine; the second stage gives .

(b) Use the law of total probability, adding the three paths that end in .
About of all items are defective, a weighted average of the three machines' rates.
For a partition and or ,
Apply Bayes' theorem with in place of and in place of .
The prior probability of spam was ; after seeing the word "free" the posterior probability is , because the word is times as common in spam as in legitimate email.
Check: .
Machine makes only of the items but is as likely as to have made a defective one, because its defect rate is more than twice as high.
(a) Find the probability that the ball is red.
(b) Given that the ball is red, find the probability that it came from bag 3.
Let be the bags chosen and be "the ball is red". The prior probabilities are , and , and , , .
(a) Law of total probability:
(b) Bayes' theorem:
The probability of bag 3 rises from to , because bag 3 always gives a red ball. (For comparison,
Let , so . Substitute into Bayes' theorem.
Multiply out.
Check: .
(a) Law of total probability:
(b) Bayes' theorem:
(c) , so the path "infected and negative" has probability , and .
A positive result raises the probability of infection from to about ; a negative result lowers it to about .
Two independent positive results make infection almost certain, even though one positive result left a chance of a false positive.

(b) (M1 for adding two paths)
(c) (M1 for Bayes' theorem or path over total)
(d) (A1) and . (M1)
(e) For two positive results, and . (M1 for squaring)
Equivalently, use the posterior from (c) as a new prior: .
(a) Find the probability that a randomly chosen student is late. [3]
(b) Given that a student is late, find the probability that the student walked. [2]
(c) Given that a student is not late, find the probability that the student travelled by bus. [3]

(a) Law of total probability. (M1 for three products, M1 for adding)
(b) (M1)
(c) (A1) and
A1
Note: Follow through from their answer to part (a).
A person is chosen at random from the population and tested.
Given that the test result is positive, find the probability that the person has the condition.
4 marks
Given that the test result is negative, find the probability that the person does not have the condition.
2 marks