Sub topic 15
The law of total probability
Prerequisites and where this fits
This chapter assumes you can compute a simple probability as favorable over total outcomes, and that you know the general multiplication rule, P(A and B) = P(A) × P(B | A). You should also be comfortable reading a tree diagram, which the previous chapter introduced. If any of those feel shaky, review them first.
The law of total probability answers a common multi-stage question: "What is the overall chance of an outcome when it can happen through several different routes?" You split the problem by the first stage, work out each route, and add the results.
The idea in one sentence
If the first stage splits the sample space into pieces that do not overlap and together cover everything, then the probability of an event E is the sum of the probabilities of reaching E through each piece.
Partitions
A partition is a set of events B1, B2, ..., Bn that satisfy two conditions:
- They are mutually exclusive: no two can happen together.
- They are exhaustive: at least one of them must happen.
Because of these two conditions, exactly one Bi occurs on every trial. Their probabilities add to 1.
The simplest partition is an event and its complement: B and "not B". Many GRE problems use only these two pieces, such as "the machine is defective" and "the machine is not defective."
The formula
For a partition B1, ..., Bn and any event E:
P(E) = P(B1) × P(E | B1) + P(B2) × P(E | B2) + ... + P(Bn) × P(E | Bn)
Each term is the general multiplication rule applied to one route: P(Bi and E) = P(Bi) × P(E | Bi). The law says that P(E) is the sum of P(Bi and E) over all i. This works because the pieces "Bi and E" do not overlap, so the addition rule for mutually exclusive events applies. The pieces together make up all of E.
For a two-piece partition, the formula becomes:
P(E) = P(B) × P(E | B) + P(not B) × P(E | not B)
Connection to the tree diagram
A tree diagram is the law of total probability drawn as a picture. The first branches are the partition. The second branches carry the conditional probabilities. To find P(E), you multiply along each path that ends in E, then add those path products.
The red paths are Start → Box 1 → Red and Start → Box 2 → Red. Their products are 0.6 × 0.5 = 0.30 and 0.4 × 0.25 = 0.10. The total is P(Red) = 0.40.
Worked example
A factory has two machines. Machine A makes 70% of the parts and Machine B makes 30%. Of Machine A's parts, 2% are defective. Of Machine B's parts, 5% are defective. What is the probability that a randomly chosen part is defective?
The partition is "made by A" and "made by B." Every part comes from exactly one machine.
- P(A) = 0.70 and P(defective | A) = 0.02, so the A route gives 0.70 × 0.02 = 0.014.
- P(B) = 0.30 and P(defective | B) = 0.05, so the B route gives 0.30 × 0.05 = 0.015.
- Add the routes: 0.014 + 0.015 = 0.029.
The answer is 2.9%.
Notice that 2.9% lies between 2% and 5%. It is a weighted average of the two defect rates, and it sits closer to 2% because Machine A makes more of the parts. This is a useful sanity check. The overall probability must always fall between the smallest and largest conditional probabilities.
Checking the law with code
This program computes the same answer using exact fractions, so there is no rounding error.
from fractions import Fraction
# Partition: which machine made the part
p_machine = {"A": Fraction(70, 100), "B": Fraction(30, 100)}
# Conditional probability of a defect given the machine
p_defect_given = {"A": Fraction(2, 100), "B": Fraction(5, 100)}
# The partition must cover everything
assert sum(p_machine.values()) == 1
# Law of total probability
p_defect = sum(p_machine[m] * p_defect_given[m] for m in p_machine)
print(p_defect) # 29/1000
print(float(p_defect)) # 0.029The assert line is worth keeping in your own habits. If the partition probabilities do not sum to 1, you have either missed a case or counted one twice.
A second example with three pieces
A student gets to school by bus, bike, or on foot. The probabilities are 0.5, 0.2, and 0.3. The probability of being late is 0.10 by bus, 0.05 by bike, and 0.02 on foot. Find P(late).
- Bus: 0.5 × 0.10 = 0.050
- Bike: 0.2 × 0.05 = 0.010
- Foot: 0.3 × 0.02 = 0.006
P(late) = 0.050 + 0.010 + 0.006 = 0.066.
First check that 0.5 + 0.2 + 0.3 = 1, so the partition is complete. Then check that 0.066 lies between 0.02 and 0.10.
Common errors
The mistakes below account for most wrong answers on this topic.
| Error | Why it is wrong | Fix | Column | Column |
|---|---|---|---|---|
| Adding the conditional probabilities, such as 0.02 + 0.05 | Conditional probabilities refer to different groups and are not weighted by group size | Multiply each by its partition probability first | ||
| Averaging the conditional probabilities without weights, such as (0.02 + 0.05) / 2 | This is correct only when the pieces are equally likely | Use the actual partition probabilities as weights | ||
| Using pieces that overlap | Overlap makes the addition step count some outcomes twice | Confirm the pieces are mutually exclusive | ||
| Using pieces that leave gaps | A missing case makes the total too small | Confirm the partition probabilities sum to 1 | ||
| Treating P(E | B) as P(B | E) | These are different quantities, usually with different values | Write the conditioning event explicitly each time |
Edge cases
One conditional probability is zero. That route simply contributes nothing. If a third machine never produces defects, it still belongs in the partition, but its term is 0.
The conditional probabilities are all equal. Then P(E) equals that common value, whatever the partition probabilities are. For example, if every machine had a 3% defect rate, the overall rate would be 3%. This also tells you that E is independent of the partition.
The partition has one certain piece. If P(B1) = 1, then P(E) = P(E | B1). The law collapses to a single term.
Without replacement. A draw from a bag without replacement often needs this law. If you ask for the probability that the second marble is red, you must consider both cases for the first draw: it was red, or it was not. Suppose a bag holds 3 red and 2 blue marbles.
- First red, second red: (3/5) × (2/4) = 6/20
- First blue, second red: (2/5) × (3/4) = 6/20
Adding gives 12/20 = 3/5. This equals the probability that the first marble is red. By symmetry, each draw position has the same unconditional probability, which is a result worth remembering on timed tests.
Strategy for the GRE
- Spot the signal. Phrases like "a randomly chosen item," "overall," or "in total," combined with groups that have different rates, point to this law.
- Name the partition. Write the groups and confirm they sum to 1.
- Write one product per group. Use group probability × conditional probability.
- Add the products.
- Check that the result lies between the smallest and largest conditional probabilities.
In quantitative comparison questions, the weighted-average bound often lets you compare quantities without computing the exact value.
Exercises
Exercise
A bag of 40 coins holds 10 coins that land heads 90% of the time and 30 coins that land heads 40% of the time. One coin is chosen at random and flipped once. What is the probability of heads?
Show answer
The partition is "biased coin" with probability 10/40 = 0.25 and "other coin" with probability 30/40 = 0.75. P(heads) = 0.25 × 0.90 + 0.75 × 0.40 = 0.225 + 0.300 = 0.525.
Exercise
In a town, 60% of residents are adults and 40% are children. Of the adults, 50% own a bicycle. Of the children, 80% own a bicycle. Without computing the exact value, between which two numbers must the overall bicycle ownership rate lie? Then compute it.
Show answer
It must lie between 0.50 and 0.80, the smallest and largest conditional rates. The exact value is 0.60 × 0.50 + 0.40 × 0.80 = 0.30 + 0.32 = 0.62.
Exercise
A bag holds 4 red and 6 blue marbles. Two marbles are drawn without replacement. What is the probability that the second marble is blue?
Show answer
Partition on the first draw. First red, second blue: (4/10) × (6/9) = 24/90. First blue, second blue: (6/10) × (5/9) = 30/90. The total is 54/90 = 3/5, which equals the probability that the first marble is blue.