The law of total probability · Mathematics Class 11–12 | StemPy Lab
Course 16.2·Lesson 1 of 3
The law of total probability
When the world splits into cases that cannot overlap and that cover every possibility, the probability of an event is a sum over the cases. Multiply the chance of each case by the chance of the event in that case, then add. This lesson shows the partition, the law of total probability, the tree diagram that adds the right paths and the usual slips.
about 25 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
split a situation into cases that do not overlap and that cover everything;
find the probability of an event with the law of total probability;
read the answer off a tree diagram by adding the paths that end in the event.
A faulty bolt
A factory has three machines. Machine M1 makes half of the bolts, M2 makes three tenths and M3 makes the rest. The machines are not equally good. About 2% of the bolts of M1 are faulty, 3% of M2 and 5% of M3. You pick a bolt at random from the whole output. What is the chance that it is faulty?
You cannot answer with one number from the list, because the bolt comes from one machine or another. So we split the question by machine, answer it for each machine, and add the answers with the right weights. That is the law of total probability.
A partition
Events E1,E2,…,En form a partition of the sample space when
they are mutually exclusive: no two can happen together;
they are exhaustive: at least one of them always happens, so their probabilities add up to 1;
each has positive probability.
The three machines are a partition. A bolt is made by exactly one machine. The simplest partition has two parts: an event B and its complement B′.
The law of total probability
Let A be any event. Because the Ei cover everything, A is the union of the pieces A∩E1,A∩E2,…, and these pieces do not overlap. So their probabilities add:
P(A)=i∑P(A∩Ei)=i∑P(Ei)P(A∣Ei).
The second step uses the multiplication rule from the previous course. In words: for each case, multiply the probability of the case by the probability of A in that case, then add. For two cases this is
P(A)=P(B)P(A∣B)+P(B′)P(A∣B′).
A tree diagram for the bolts of three machines. The first branches go to M1 with probability 0.5, M2 with 0.3 and M3 with 0.2. From each machine, one branch goes to faulty and one to fine. The faulty probabilities are 0.02 for M1, 0.03 for M2 and 0.05 for M3. The ends show the probability of each path: M1 faulty 0.01, M1 fine 0.49, M2 faulty 0.009, M2 fine 0.291, M3 faulty 0.01 and M3 fine 0.19. The title says the faulty paths add up to 0.029.
The tree diagram shows the same idea. Each path that ends in "faulty" has the probability of its machine times the faulty rate of that machine. The answer is the sum of those paths.
A worked example with the machines
The paths.M1 and faulty: 0.5×0.02=0.01. M2 and faulty: 0.3×0.03=0.009. M3 and faulty: 0.2×0.05=0.01.
The sum.P(faulty)=0.01+0.009+0.01=0.029.
Check. The overall rate is 2.9%. It lies between the lowest rate 2% and the highest rate 5%, and it is nearer to the rates of the big machines, which is right.
A second example with urns
A fair die is thrown. If it shows 1 or 2, a ball is drawn from Urn I, which holds 3 red and 2 white balls. Otherwise a ball is drawn from Urn II, which holds 1 red and 4 white balls. Find the probability that the ball is red.
The cases are "Urn I" with probability 31 and "Urn II" with probability 32. Then
P(red)=31×53+32×51=153+152=31.
Practise with new numbers
Try it in Python
The program adds the three paths of the factory with exact fractions. It also checks that the shares of the machines add up to 1, which any partition must do.
Common mistakes
Cases that do not cover everything. If the shares add up to less than 1, a case is missing.
Cases that overlap. A bolt cannot come from two machines. If cases overlap, one path is counted twice.
Adding the conditional probabilities. Do not add 0.02+0.03+0.05. Weight each one by the share of its machine first.
Using the wrong complement. The probability of the second case in a two-case partition is 1−P(B).
Remember these
A partition is a set of events that are mutually exclusive and exhaustive, with positive probabilities.
P(A)=∑iP(Ei)P(A∣Ei).
In a tree, add all the paths that end in A.
The answer lies between the smallest and the largest of the P(A∣Ei).
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Three events have probabilities 0.3, 0.45 and 0.25. Their probabilities add up to 1. Is that enough for them to form a partition?
Given P(B)=0.3, P(A∣B)=0.8 and P(A∣B′)=0.2, find P(A).
A box has 100 bulbs. Supplier X made 60 of them, and 5% of these are faulty. Supplier Y made the other 40, and 10% of these are faulty. A bulb is chosen at random. Find the probability that it is faulty.
A student passes a test with probability 0.9 if she has studied and 0.4 if she has not. The chance that she studied is 0.7. Find the probability that she passes.
Why must the cases of a partition be mutually exclusive?
References
OpenStax, Introductory Statistics, Chapter 3, section on tree and Venn diagrams.
NCERT, Mathematics Part II for Class XII, Chapter 13, section on partition of a sample space and the theorem of total probability.
Enroll free in Total Probability and Bayes' Theorem
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.