Bayes theorem
A doctor tells a patient that a test for a rare disease has come back positive, and the test is "99% accurate." How worried should the patient actually be? The instinct is to say "99% worried" — but that instinct is almost always wrong, and the reason is a piece of mathematics that runs conditional probability backwards. Every conditional probability statement so far in this chapter has answered a forward question: given the cause, what is the chance of the effect? A bag is chosen, then a ball is drawn — what is the chance the ball is red? Bayes' theorem flips that question around. Given that the effect has already happened — the ball drawn is red, the test came back positive — what is the chance it arose from one particular cause among several possible ones? It takes the total probability theorem, which adds up the contributions of every possible route to an outcome, and asks what fraction of that total came from one specific route. This is the capstone result of the Probability chapter, sitting directly on top of conditional probability, the multiplication theorem, and the total probability theorem.
Bayes' theorem finds the probability of a particular cause given that an effect has been observed, by dividing that cause's contribution to the effect by the total probability of the effect summed over all possible causes.
The core idea
Setting up the ingredients. Bayes' theorem needs a partition of the sample space into events — mutually exclusive events whose union is all of , each with — together with any event with that can occur alongside one of these . Think of the as the possible "causes" or "routes" (which bag was picked, which machine made the item, whether the patient has the disease) and as the observed "effect" (the ball is red, the item is defective, the test is positive).
The formula. For each ,
where: is the prior probability of cause (its probability before any evidence is known), is the likelihood of seeing the effect if is true, and is the posterior probability — the updated probability of once it is known that has occurred. The denominator is nothing but , computed exactly as in the total probability theorem: .
Reading the formula as a fraction of a whole. The numerator is just one term of the sum sitting in the denominator. So Bayes' theorem is really asking: of all the probability mass that flows into from every possible cause, what share came specifically from cause ? This "share of the total" reading is worth holding onto — it explains every worked example below.
Priors update into posteriors. Before the ball is drawn, (probability Bag I was chosen) is just — a guess based only on the setup, before any evidence. After the ball is drawn and seen to be red, that guess is revised into , a sharper number that accounts for the new evidence. This updating process — prior in, evidence applied, posterior out — is the entire content of the theorem, and it is exactly the same logic used far beyond this syllabus, in areas like medical screening, spam filtering, and machine learning.
Show that , the probability that cause occurred given that effect has already been observed, must equal the ratio of 's own contribution to over the combined contribution of every possible cause to , using nothing but the definition of conditional probability, the multiplication theorem, and the total probability theorem already established for this partition.
Step 1. Start from the definition of conditional probability applied to given :
This is the standard definition — nothing new is assumed yet, only that both and are events in the same sample space with .
Step 2. Rewrite the numerator using the multiplication theorem, , which holds because and :
At this stage the formula already resembles Bayes' theorem, but the denominator is not yet expressed in terms of the partition.
Step 3. Expand using the total probability theorem. Since partition , the event decomposes as the disjoint union , so
Step 4. Substitute this expanded form of from Step 3 into the denominator of the expression from Step 2:
This is exactly Bayes' theorem, and it holds for every , so it can be applied to any one of the causes once the priors and likelihoods are known.
Worked example
Bag I contains 4 red and 4 black balls, Bag II contains 2 red and 6 black balls. One bag is chosen at random and a ball is drawn from it, and the ball turns out to be red. Find the probability that the ball was drawn from Bag I.
Step 1. Identify the partition and the priors. Let = "Bag I chosen," = "Bag II chosen." Since the bag is chosen at random from two bags, .
Step 2. Identify the likelihoods. Let = "ball drawn is red." Bag I has 4 red out of 8 balls, and Bag II has 2 red out of 8 balls, so
Step 3. Find using the total probability theorem.
Step 4. Apply Bayes' theorem for .
So, given that the drawn ball is red, the probability it came from Bag I is . This is sensible: Bag I has a higher proportion of red balls than Bag II, so observing a red ball should shift belief toward Bag I over its plain prior of .
Competitive stretch
A diagnostic test is 99% accurate both ways: for a diseased person testing positive, and a false positive rate of for a healthy person, where only of the population actually has the disease (, ). Then , and Bayes' theorem gives
Even with a "99% accurate" test, a person who tests positive has only about a 33.2% chance of actually having the disease — because the disease is rare, the false positives drawn from the large healthy population outnumber the true positives from the tiny diseased population. Compare this against Bag I's example: there, equal priors ( vs ) combined with very different likelihoods still moved the posterior a lot; here, a low prior () pulls a seemingly strong likelihood () down to roughly one-third. The prior always matters as much as the likelihood.
Common traps
- Mistaking the test's "accuracy" for the final posterior. A high does not make equally high — a small prior can pull the posterior down sharply, as in the diagnostic-test stretch example above.
- Forgetting to compute via the total probability theorem first. The denominator of Bayes' theorem is rarely given directly; it must be built by summing over every before the formula can be applied.
- Dropping partition events from the denominator sum. With three or more possible causes, every single must appear in the sum — not just the one whose posterior is being computed.
- Swapping prior and posterior. is the probability before evidence is known; is the probability after is known. Writing one where the other belongs silently breaks the whole calculation.
Ask the tutor: Want to see why a 99% accurate test can still leave a patient only about 33% likely to have the disease, or need help setting up the priors and likelihoods for your own Bayes' theorem word problem?
Why is Bayes theorem called reversing the conditional probability
Ordinary conditional probability, like , answers a forward question: given the cause, what is the chance of the effect. Bayes' theorem answers the reverse question: given that the effect has already happened, what is the chance it came from a particular cause. It literally swaps which event sits after the "given" bar, which is why textbooks describe it as running conditional probability backwards.
Do I need to memorise the total probability theorem separately from Bayes theorem
Yes, and they are closely linked, not identical. The total probability theorem computes only the denominator, . Bayes' theorem reuses that exact sum as its denominator and adds the specific numerator on top, to isolate one cause's share. In practice, solving a Bayes' theorem problem almost always means computing the total probability theorem's answer first, then dividing.
What happens if there are three or more possible causes instead of two
Nothing changes structurally — the formula still reads , only now the sum in the denominator runs over three, four, or however many partition events exist. The main danger is arithmetic: every single term must be included in that sum, or the denominator will be too small and every posterior will come out inflated.