Sub topic 2
Sample Space and Events
This chapter assumes you can compute factorials, permutations and combinations at a basic level. It also assumes you know what a standard die, a coin and a 52-card deck contain. Every probability problem starts the same way: say exactly what can happen, then say which of those outcomes you care about. This chapter covers that first step.
Experiments, Outcomes and the Sample Space
A random experiment is a process whose result is not known in advance, but whose possible results are all known. Rolling a die, tossing a coin and drawing a card are random experiments.
An outcome is one single, indivisible result of the experiment. The sample space is the set of all possible outcomes. It is usually written S, and the number of outcomes in it is written n(S).
| Experiment | Sample space S | n(S) |
|---|---|---|
| Toss one coin | {H, T} | 2 |
| Roll one die | {1, 2, 3, 4, 5, 6} | 6 |
| Toss two coins | {HH, HT, TH, TT} | 4 |
| Roll two dice | 36 ordered pairs (a, b) | 36 |
| Draw one card from a deck | 52 cards | 52 |
Two requirements make a sample space usable:
- Exhaustive. Every possible result of the experiment is in S.
- Mutually exclusive outcomes. Exactly one outcome happens each time. Two different outcomes cannot occur together.
Choosing the Right Level of Detail
The same experiment can have more than one sample space. For two dice you could record only the sum, giving S = {2, 3, ..., 12}. That is a valid description, but the 11 outcomes are not equally likely. A sum of 7 can happen in six ways, while a sum of 2 can happen in only one way.
For CAT counting problems, choose the sample space whose outcomes are equally likely. For two dice, use the 36 ordered pairs. Chapter 3 depends on this choice, because classical probability only works when the outcomes are equally likely.
Events as Subsets
An event is any collection of outcomes from the sample space, that is, a subset of S. We say the event "occurs" if the outcome that actually happens belongs to that subset. Events are usually named with capital letters such as A, B or E.
Examples for one roll of a die, where S = {1, 2, 3, 4, 5, 6}:
- A = "an even number" = {2, 4, 6}, so n(A) = 3.
- B = "a number greater than 4" = {5, 6}, so n(B) = 2.
- C = "a number less than 1" = { }, which is impossible.
- D = "a number from 1 to 6" = S, which is certain.
An event with a single outcome is a simple event. An event with no outcomes is the impossible event, written ∅. The event S itself is the certain event.
Building Events from Words
Most of the work in a word problem is translating English into a subset. The skill is to write the outcomes down, not to guess a number.
from itertools import product
# Sample space for two dice: all ordered pairs
S = list(product(range(1, 7), repeat=2))
# Event A: the sum is 8
A = [o for o in S if sum(o) == 8]
# Event B: at least one die shows a 6
B = [o for o in S if 6 in o]
print(len(S)) # 36
print(A) # [(2, 6), (3, 5), (4, 4), (5, 3), (6, 2)]
print(len(A)) # 5
print(len(B)) # 11Notice that (2, 6) and (6, 2) are different outcomes. The two dice are distinct, even if they look identical. This is the most common reason for miscounting.
Combining Events: Union, Intersection and Complement
New events are built from old ones using set operations. Each operation matches a word in the problem.
| Operation | Symbol | Meaning in words | Keyword |
|---|---|---|---|
| Union | A ∪ B | A occurs, or B occurs, or both | "or", "at least one of" |
| Intersection | A ∩ B | Both A and B occur | "and", "both" |
| Complement | A′ | A does not occur | "not", "none" |
| Difference | A − B | A occurs but B does not | "A but not B" |
Take one die roll with A = {2, 4, 6} (even) and B = {5, 6} (greater than 4).
- A ∪ B = {2, 4, 5, 6}
- A ∩ B = {6}
- A′ = {1, 3, 5}
- A − B = {2, 4}
The size of a union follows the counting rule n(A ∪ B) = n(A) + n(B) − n(A ∩ B). Here 3 + 2 − 1 = 4, which matches the list. Outcomes in both sets would be counted twice if you simply added, so you subtract the overlap once. This counting rule becomes the addition rule for probabilities in a later chapter.
Mutually Exclusive and Exhaustive Events
Two events are mutually exclusive (also called disjoint) if they cannot occur together, so A ∩ B = ∅. On one die roll, "even" = {2, 4, 6} and "prime and odd" = {3, 5} are mutually exclusive. "Even" and "greater than 4" are not, because both contain 6.
A set of events is exhaustive if their union is the whole sample space. A set of events that is both mutually exclusive and exhaustive is a partition of S. Every outcome lands in exactly one of the events.
Two simple partitions appear constantly:
- Any event A and its complement A′ form a partition of S.
- The simple events themselves, such as {1}, {2}, ..., {6}, form a partition.
A Procedure for Setting Up Any Problem
Use the same four steps each time.
- Name the experiment. Decide what is being done: one die, two dice, drawing 3 cards, and so on.
- Fix the sample space. Choose a description where outcomes are equally likely. State whether order matters and whether items are distinct.
- Translate the event. Write the condition as a subset, using or, and, not.
- Count both sets. Find n(S) and n(A), using lists for small cases and permutations or combinations for large ones.
The order question in step 2 matters most when counting with combinations. Suppose a bag has 5 red and 3 blue balls and you draw 2 at once. If you treat the draw as an unordered pair, then n(S) = C(8, 2) = 28. If you treat it as an ordered draw, then n(S) = 8 × 7 = 56. Both are valid sample spaces, provided you count the event in the same way. Mixing the two gives wrong answers.
from math import comb, perm
# Unordered view: choose 2 of 8 balls
n_S_unordered = comb(8, 2) # 28
n_A_unordered = comb(5, 2) # both red: 10
# Ordered view: arrange 2 of 8 balls
n_S_ordered = perm(8, 2) # 56
n_A_ordered = perm(5, 2) # both red: 20
print(n_A_unordered / n_S_unordered) # 0.35714285714285715
print(n_A_ordered / n_S_ordered) # 0.35714285714285715Both views give 5/14, as long as the numerator and the denominator use the same convention.
Worked Example: Three Coins
Three fair coins are tossed. Let A = "exactly two heads" and B = "the first coin is a head".
Sample space: each coin has 2 results, so n(S) = 2 × 2 × 2 = 8. The outcomes are HHH, HHT, HTH, HTT, THH, THT, TTH, TTT.
- A = {HHT, HTH, THH}, so n(A) = 3. This matches C(3, 2) = 3.
- B = {HHH, HHT, HTH, HTT}, so n(B) = 4.
- A ∩ B = {HHT, HTH}, so n(A ∩ B) = 2.
- A ∪ B = {HHH, HHT, HTH, HTT, THH}, so n(A ∪ B) = 5.
Check with the counting rule: 3 + 4 − 2 = 5. A and B are not mutually exclusive, since they share HHT and HTH.
from itertools import product
S = ["".join(t) for t in product("HT", repeat=3)]
A = {s for s in S if s.count("H") == 2}
B = {s for s in S if s[0] == "H"}
print(len(S), len(A), len(B)) # 8 3 4
print(sorted(A & B)) # ['HHT', 'HTH']
print(len(A | B)) # 5Common Errors
- Unequal outcomes treated as equal. Using sums {2, ..., 12} as if each sum were equally likely. Use ordered pairs instead.
- Treating identical-looking objects as identical. Two red balls are still two different balls when counting. Label them in your head.
- Mixing ordered and unordered counts. Use permutations in both numerator and denominator, or combinations in both.
- Forgetting the overlap. Adding n(A) and n(B) when the events share outcomes counts those outcomes twice.
- Confusing "at least" with "exactly". "At least 2 heads in 3 tosses" is {HHH, HHT, HTH, THH}, which has 4 outcomes, not 3.
- Leaving out outcomes. In a listing, check the total against the product rule. For three coins you must reach 8.
Exercises
Exercise
Two fair dice are rolled. Let A = "the sum is at least 10" and B = "the two numbers are equal". Find n(S), n(A), n(B), n(A ∩ B), and n(A ∪ B).
Show answer
n(S) = 36. A = {(4,6), (5,5), (6,4), (5,6), (6,5), (6,6)}, so n(A) = 6. B = {(1,1), (2,2), (3,3), (4,4), (5,5), (6,6)}, so n(B) = 6. The overlap is {(5,5), (6,6)}, so n(A ∩ B) = 2. Then n(A ∪ B) = 6 + 6 − 2 = 10.
Exercise
A committee of 3 is chosen from 4 men and 3 women. Let E = "the committee has exactly one woman". Find n(S) and n(E), using combinations.
Show answer
n(S) = C(7, 3) = 35. For E, choose 1 woman from 3 and 2 men from 4: n(E) = C(3, 1) × C(4, 2) = 3 × 6 = 18.
Exercise
On one roll of a die, A = {1, 2, 3}, B = {3, 4}, and C = {5, 6}. Which pairs of these events are mutually exclusive? Is the set {A, B, C} exhaustive?
Show answer
A and C are mutually exclusive, and B and C are mutually exclusive, because they share no outcome. A and B share the outcome 3, so they are not. The union A ∪ B ∪ C = {1, 2, 3, 4, 5, 6} = S, so the set is exhaustive. It is not a partition, because A and B overlap.