Sub topic 6
Conditional Probability
This chapter assumes you can count outcomes with permutations and combinations and can compute classical probability as favourable over total. It also assumes you are comfortable with fractions and with the complement rule.
What "given" means
A conditional probability is the probability of an event after you learn that another event has happened. Write it as P(A | B), read "the probability of A given B".
The formula is:
P(A | B) = P(A ∩ B) / P(B), where P(B) > 0.
Here A ∩ B means "both A and B occur". The formula has a simple meaning. Once you know B has happened, outcomes outside B are impossible. B becomes your new sample space, and you ask what fraction of B also lies in A.
With equally likely outcomes this reduces to counting:
P(A | B) = (number of outcomes in both A and B) / (number of outcomes in B)
So the working method is to shrink the sample space to B, then count A inside it.
A first worked example with dice
Two fair dice are rolled. Given that the first die is even, what is the probability that the sum is 8?
- The first die is even: 3 choices for it and 6 for the second die, so 18 outcomes. This is the reduced sample space.
- Within those, the sum is 8 for (2,6), (4,4) and (6,2). That is 3 outcomes.
- The answer is 3/18 = 1/6.
You can confirm it by enumeration:
from fractions import Fraction
from itertools import product
outcomes = list(product(range(1, 7), repeat=2))
given = [o for o in outcomes if o[0] % 2 == 0]
both = [o for o in given if sum(o) == 8]
print(Fraction(len(both), len(given))) # 1/6Using the formula gives the same result. P(first even and sum 8) = 3/36 and P(first even) = 18/36, so the ratio is 3/18 = 1/6.
The direction matters
P(A | B) and P(B | A) usually differ, because they have different denominators. One card is drawn from a 52-card deck.
- P(King | face card) = 4/12 = 1/3, because there are 12 face cards and 4 of them are kings.
- P(face card | King) = 4/4 = 1, because every king is a face card.
The numerator is the same in both cases (4 cards that are both). Only the reduced sample space changes.
Many CAT errors come from reading "A given B" backwards. The event after the word "given" (or "if", "provided that", "knowing that") is the one that goes in the denominator.
Reading a two-way table
Conditional probabilities are easy to read from a table of counts. In a group of 100 candidates, 60 passed the quant test, 50 passed the verbal test, and 30 passed both.
| Row | Passed verbal | Failed verbal | Total |
|---|---|---|---|
| Passed quant | 30 | 30 | 60 |
| Failed quant | 20 | 20 | 40 |
| Total | 50 | 50 | 100 |
The cells follow from the totals: 60 − 30 = 30 passed quant only, 50 − 30 = 20 passed verbal only, and 100 − (30 + 30 + 20) = 20 passed neither.
- P(verbal | quant) = 30/60 = 1/2. Look only at the "Passed quant" row.
- P(quant | verbal) = 30/50 = 3/5. Look only at the "Passed verbal" column.
- P(passed neither | failed quant) = 20/40 = 1/2.
Conditioning means choosing one row or column and dividing by its total.
Conditional complement
Given B, the event A either happens or does not, so:
P(A' | B) = 1 − P(A | B)
The condition must stay the same on both sides. P(A' | B) is not 1 − P(A | B') and not 1 − P(A). In the table, P(failed verbal | passed quant) = 1 − 1/2 = 1/2, which matches 30/60.
Sequential draws: the multiplication form
Rearranging the definition gives P(A ∩ B) = P(B) × P(A | B). This is the multiplication rule. It is the natural tool for draws without replacement, where each draw changes what remains.
A bag has 5 red and 3 blue balls. Two are drawn without replacement.
- P(first red) = 5/8.
- After a red is removed, 4 red and 3 blue remain, so P(second red | first red) = 4/7.
- P(both red) = 5/8 × 4/7 = 20/56 = 5/14.
This agrees with the counting method, C(5,2)/C(8,2) = 10/28 = 5/14:
from math import comb
from fractions import Fraction
# Sequential: P(R1) * P(R2 | R1)
sequential = Fraction(5, 8) * Fraction(4, 7)
# Counting: choose 2 of the 5 red balls out of all pairs from 8
counting = Fraction(comb(5, 2), comb(8, 2))
print(sequential, counting, sequential == counting) # 5/14 5/14 TrueOn a tree, the number on each second-level branch is a conditional probability. Multiplying along a path gives the probability of the whole path.
Using conditional probability to test independence
Events A and B are independent when learning B does not change the probability of A. That means:
P(A | B) = P(A)
In the table above, P(verbal) = 50/100 = 1/2 and P(verbal | quant) = 1/2. The two are equal, so passing verbal and passing quant are independent in this group. Equivalently, P(quant) × P(verbal) = 0.6 × 0.5 = 0.3 = P(both).
Do not confuse independent with mutually exclusive. If A and B are mutually exclusive and both have positive probability, then P(A | B) = 0, which is different from P(A). So such events are never independent.
Where wording hides the condition
The two-children problem shows how the exact wording changes the reduced sample space. A family has two children. List the outcomes as (elder, younger): BB, BG, GB, GG, all equally likely.
- Given that at least one child is a boy, the reduced space is BB, BG, GB. P(both boys) = 1/3.
- Given that the elder child is a boy, the reduced space is BB, BG. P(both boys) = 1/2.
from fractions import Fraction
from itertools import product
families = list(product("BG", repeat=2)) # (elder, younger)
at_least_one = [f for f in families if "B" in f]
both_given_one = [f for f in at_least_one if f == ("B", "B")]
print(Fraction(len(both_given_one), len(at_least_one))) # 1/3
elder_boy = [f for f in families if f[0] == "B"]
both_given_elder = [f for f in elder_boy if f[1] == "B"]
print(Fraction(len(both_given_elder), len(elder_boy))) # 1/2A symmetry shortcut
Sometimes a condition looks like it should change the answer but does not. A bag has 4 red and 6 blue balls, and two are drawn without replacement. What is P(first is red | second is red)?
The formula gives:
- P(R1 ∩ R2) = 4/10 × 3/9 = 2/15
- P(R2) = 4/10 = 2/5
- Ratio = (2/15) / (2/5) = 1/3
You can reach this directly. Given that the second ball is red, the other 9 positions' balls are a random arrangement of the remaining 3 red and 6 blue, so the first ball is red with probability 3/9 = 1/3. Without replacement, the order of draws does not matter, so conditioning on a later draw works like conditioning on an earlier one.
Common traps
- Swapped denominators. The denominator is the probability of the given event, not of the event you want.
- Treating "given" as "and". P(A ∩ B) is a fraction of the whole sample space. P(A | B) is a fraction of B only, so it is larger or equal.
- Forgetting to update the pool. In draws without replacement, the second-stage probability must use the changed counts.
- Assuming independence. Check P(A | B) = P(A) before multiplying plain probabilities.
- Impossible conditions. The formula needs P(B) > 0. If the given event cannot happen, the conditional probability is undefined.
Summary of the method
- Identify the given event B (the words "given", "if", "knowing that").
- Shrink the sample space to B, either by listing or by reading a row or column.
- Count or compute the part of B where A also holds.
- Divide, and check that the answer is at most 1 and that the denominator is the given event.
Exercise
Two fair dice are rolled. Given that at least one die shows a 6, what is the probability that the sum is at least 10?
Show answer
Outcomes with at least one 6: 36 − 25 = 11. Of these, the sum is at least 10 for (6,4), (4,6), (6,5), (5,6) and (6,6), which is 5 outcomes. The probability is 5/11.
Exercise
A bag has 4 red and 6 blue balls. Two balls are drawn one after another without replacement. Find P(first is red | second is red) using the formula P(A ∩ B) / P(B), and explain why the answer is not 4/10.
Show answer
P(both red) = 4/10 × 3/9 = 2/15 and P(second red) = 4/10 = 2/5, so the answer is (2/15) / (2/5) = 1/3. It is not 4/10 because knowing the second ball is red uses up one red ball, leaving 3 red among the other 9 balls, so the first ball is red with probability 3/9 = 1/3.
Exercise
In a class of 50 students, 30 study French, 20 study German and 10 study both. A student who studies French is chosen. What is the probability that this student also studies German? Are the two events independent?
Show answer
P(German | French) = 10/30 = 1/3. P(German) = 20/50 = 2/5, which is not equal to 1/3, so the events are not independent.