The Law of Total Probability
Partitioning a sample space to compute awkward probabilities, with tree diagrams.
Assumes you know
The Law of Total Probability
Intuition first
Sometimes a probability is awkward to compute directly but easy to compute once you know which situation you are in.
"What is the chance a randomly chosen visitor buys something?" is hard to answer in one step. But split visitors into mobile and desktop, and each piece becomes easy: mobile visitors buy 20% of the time, desktop visitors 40% of the time. If 60% of traffic is mobile, the overall rate is the weighted average
That is the whole law. Break the world into non-overlapping cases, solve each, then recombine weighted by how likely each case is.
The only thing that ever goes wrong is the splitting: the cases must not overlap, and together they must cover everything.
Partitions
A collection of events is a partition of the sample space when two conditions hold:
Exactly one of the occurs, always. The simplest partition is any event and its complement: .
| Symbol | Meaning | Read aloud |
|---|---|---|
| B₁ … Bₙ | A partition — mutually exclusive and exhaustive events | B one through B n |
| P(Bᵢ) | Prior weight of case i — how likely that case is | P of B i |
| P(A | Bᵢ) | Probability of A within case i | P of A given B i |
| Σ | Sum over all cases | sum |
The law
For any event and any partition with :
The two-case version, used constantly:
Derivation from the axiomsAdvanced
Because the partition , the event can be written as intersected with the whole space, then distributed:
These pieces are pairwise disjoint. If then
so Axiom 3 (additivity) applies:
Finally rewrite each joint using the multiplication rule, :
Two ingredients only: disjointness lets you add, and the multiplication rule converts joints into conditionals.
A useful sanity check
Because the weights sum to 1, the result is a genuine weighted average. It must therefore lie between the smallest and largest of the conditional probabilities:
In the shop example, sits between and . If your answer falls outside that range, the arithmetic is wrong — this catches errors instantly.
Solved problem 1 · Three factories
A company sources components from three factories. Factory A supplies 50% of components with a 2% defect rate; factory B supplies 30% with a 3% defect rate; factory C supplies 20% with a 5% defect rate. A component is picked at random. What is the probability it is defective?
Step 1 — identify the partition and check it
The factories partition the components: a component comes from exactly one factory, and the three cover all supply.
Check exhaustiveness:
Step 2 — write the conditional defect rates
Let = "the component is defective".
Step 3 — apply the law term by term
Step 4 — sanity check
The conditional rates range from 0.02 to 0.05, and lies inside that range
It sits near the low end, as expected: the largest supplier also has the lowest defect rate.
Answer
, that is 2.9%.
Solved problem 2 · A two-stage experiment
Urn I contains 4 red and 6 blue balls. Urn II contains 7 red and 3 blue balls. A fair coin is tossed: on heads we draw from urn I, on tails from urn II. What is the probability the drawn ball is red?
Step 1 — the partition is the coin toss
These are mutually exclusive and exhaustive, so they form a valid partition.
Step 2 — conditional probabilities within each urn
Step 3 — combine
Step 4 — check
With equal weights the answer must be the plain average of 0.4 and 0.7, which is
Answer
.
Why this matters
The law of total probability is not a standalone trick. It is the denominator of Bayes' theorem, and it appears throughout the curriculum:
- Bayes' theorem uses it to compute , the normalising constant.
- Marginalisation in probabilistic models is this law: summing a joint distribution over the values of a hidden variable.
- Variable elimination in Bayesian networks applies it repeatedly, which is exactly why that algorithm is tractable.
- Mixture models define — a Gaussian mixture is the law of total probability with Gaussian components.
Exercise 1
A student passes an exam with probability 0.9 if they studied and 0.3 if they did not. 70% of students study. What fraction of students pass?
Show solutionHide solution
Partition on studying, and , with and (these sum to 1 ✓).
Check: lies between and ✓, and closer to because most students study.
Exercise 2
A box holds 3 fair coins and 1 biased coin that lands heads with probability 0.8. A coin is chosen at random and tossed. Find the probability of heads.
Show solutionHide solution
Partition on which coin was chosen:
Check: between 0.5 and 0.8 ✓, near the low end since fair coins dominate.
Exercise 3
A student writes: "60% of emails are from known senders and 25% of emails are spam, so ." Identify the error.
Show solutionHide solution
The weights must be the probabilities of the partition cases, not a mix of a case probability and the very quantity being computed.
The partition is , so the weights are and :
The is itself — the left-hand side. Using it as a weight is circular, and since the weights do not even form a partition, which is the quickest way to spot the mistake.
Next: Bayes' Theorem — which is this law run backwards, and the single most useful result in the module.