Sub topic 10
Total Probability and Bayes' Theorem
Assume you can use fractions, conditional probability, the multiplication rule, and basic counting. This chapter handles problems with two stages, such as choosing a bag and then drawing a ball. The key difficulty is keeping track of all possible routes to an outcome.
The law of total probability
Suppose an experiment can begin through mutually exclusive cases \(B1, B2, \ldots, B_n\). These cases cover every possibility. An event \(A\) may happen through any one of them.
The law of total probability is:
P(A) = P(B₁)P(A | B₁) + P(B₂)P(A | B₂) + ... + P(Bₙ)P(A | Bₙ)
Here, P(A | B₁) means the probability of A when B₁ has already happened.
For two bags:
- Bag 1 is chosen with probability 1/2 and contains a red ball with probability 2/5.
- Bag 2 is chosen with probability 1/2 and contains a red ball with probability 3/4.
The total probability of drawing red is:
P(R) = (1/2)(2/5) + (1/2)(3/4) P(R) = 1/5 + 3/8 = 23/40
The multiplication in each term represents one complete route. The addition combines routes that cannot happen together.
Reading a probability tree
A probability tree displays these routes clearly. Multiply probabilities along a branch. Add probabilities of branches that lead to the same final event.
A tree is especially useful when the question contains “given that,” because it separates the original routes before you reverse the condition.
Bayes' theorem
Bayes' theorem finds the probability of a cause after observing an outcome. For example, after drawing a red ball, what is the probability it came from Bag 1?
Bayes' theorem is:
P(B₁ | A) = P(B₁)P(A | B₁) / P(A)
Using the earlier values:
P(Bag 1 | R) = [(1/2)(2/5)] / (23/40) P(Bag 1 | R) = (1/5) / (23/40) = 8/23
Although both bags were initially equally likely, Bag 2 is more likely to produce red. Therefore, after observing red, Bag 2 becomes more likely as the source.
from fractions import Fraction
# Bag 1 and Bag 2 are initially equally likely.
via_bag1 = Fraction(1, 2) * Fraction(2, 5)
via_bag2 = Fraction(1, 2) * Fraction(3, 4)
probability_red = via_bag1 + via_bag2
probability_bag1_given_red = via_bag1 / probability_red
print(probability_bag1_given_red) # 8/23Common errors and CAT shortcuts
Do not confuse P(A | B) with P(B | A). The first asks for the chance of A after B is known. The second asks for the chance of B after A is known. They usually have different values.
Also, do not average conditional probabilities unless the cases are equally likely. If Bag 1 is selected 90% of the time and Bag 2 only 10% of the time, their contributions must be weighted accordingly.
For a CAT question:
- Identify the initial cases, such as bags, factories, or groups.
- Write the probability of each case.
- Write the conditional probability of the observed event within each case.
- Multiply along each route.
- Add routes for total probability.
- If the question asks for the source after observing an event, divide the desired route by the total event probability.
Exercise
A factory gets 60% of its parts from Supplier A, whose defect rate is 2%, and 40% from Supplier B, whose defect rate is 5%. If a randomly selected part is defective, what is the probability it came from Supplier B?
Show answer
P(D) = (0.6)(0.02) + (0.4)(0.05) = 0.032. Therefore, P(B | D) = (0.4)(0.05) / 0.032 = 0.625, or 62.5%.