05-01: Exercises — Probability Basics¶
Notes reference: 05-01: Probability Basics
Q1: Sample spaces¶
Write the sample space and its size for each experiment.
- Toss a coin three times
- Roll a die and toss a coin
- Draw one card and note the suit
- Two children, recording sex in birth order
Solution
1. S = {HHH, HHT, HTH, HTT, THH, THT, TTH, TTT} n(S) = 8 = 2³
2. S = {(1,H),(1,T),(2,H),(2,T),…,(6,H),(6,T)} n(S) = 12 = 6 × 2
3. S = {Hearts, Diamonds, Clubs, Spades} n(S) = 4
4. S = {BB, BG, GB, GG} n(S) = 4 = 2²
Common error in #4: writing S = {two boys, one of each, two girls} with n(S) = 3. Those three outcomes are not equally likely — "one of each" happens two ways, so P(one of each) = 2/4, not 1/3.
Q2: Classical probability with a die¶
Roll one fair die. Find:
P(even)P(greater than 4)P(prime)P(not 3)P(0)P(less than 10)
Solution
S = {1,2,3,4,5,6}, n(S) = 6
1. P(even) = {2,4,6} → 3/6 = 0.5000
2. P(> 4) = {5,6} → 2/6 = 0.3333
3. P(prime) = {2,3,5} → 3/6 = 0.5000
4. P(not 3) = 1 − 1/6 → 5/6 = 0.8333 (complement rule)
5. P(0) = impossible→ 0
6. P(< 10) = certain → 1
Q3: Two dice¶
Roll two fair dice, n(S) = 36. Find:
P(sum = 8)P(sum ≤ 4)P(doubles)P(at least one 6)P(sum is odd)
Solution
1. Sum 8: (2,6)(3,5)(4,4)(5,3)(6,2) → 5/36 = 0.1389
2. Sum ≤ 4: sum 2 (1 way) + sum 3 (2) + sum 4 (3) = 6 → 6/36 = 0.1667
3. Doubles: (1,1)(2,2)(3,3)(4,4)(5,5)(6,6) → 6/36 = 0.1667
4. At least one 6 — use the COMPLEMENT:
P(no 6) = (5/6)(5/6) = 25/36
P(at least one 6) = 1 − 25/36 = 11/36 = 0.3056
5. A sum is odd exactly when one die is odd and the other even:
(3 odd × 3 even) + (3 even × 3 odd) = 9 + 9 = 18 → 18/36 = 0.5000
S <- expand.grid(d1 = 1:6, d2 = 1:6)
sums <- S$d1 + S$d2
mean(sums == 8) # 0.1389
mean(sums <= 4) # 0.1667
mean(S$d1 == S$d2) # 0.1667
mean(S$d1 == 6 | S$d2 == 6) # 0.3056
mean(sums %% 2 == 1) # 0.5
Q4: Empirical probability¶
A quality inspector records 500 items: 468 good, 24 minor defects, 8 major defects.
P(minor defect)P(any defect)P(good)— two ways- Estimate the number of defective items in a 12,000-unit shipment.
Solution
1. P(minor) = 24/500 = 0.048
2. P(any defect) = (24 + 8)/500 = 32/500 = 0.064
3. P(good) = 468/500 = 0.936
or 1 − 0.064 = 0.936 (complement) ✓ agree
4. Expected defectives = 12,000 × 0.064 = 768 units
=COUNTIF(B2:B501,"minor")/COUNTA(B2:B501) ' 0.048
=1-COUNTIF(B2:B501,"good")/COUNTA(B2:B501) ' 0.064
Q5: The complement rule saves work¶
A machine produces items with a 4% defect rate. Ten items are inspected.
P(none defective)P(at least one defective)- Why is #2 easier by the complement?
Solution
1. P(none) = (0.96)^10 = 0.6648
2. P(at least one) = 1 − 0.6648 = 0.3352
3. Directly, "at least one" means
P(1) + P(2) + P(3) + … + P(10)
— ten separate binomial terms. The complement is ONE calculation.
Note how large 33.5% is: a 4% defect rate feels small, but inspect ten
items and a third of the batches contain at least one bad unit.
Q6: Odds¶
P(win) = 0.30. Give the odds in favour and the odds against.- Odds against an event are 7:3. Find
P(event). - A horse is quoted at odds of 5:1 against. What probability does that imply?
Solution
1. Odds in favour = P : (1−P) = 0.30 : 0.70 = 3 : 7
Odds against = 0.70 : 0.30 = 7 : 3
2. Odds AGAINST 7:3 → odds IN FAVOUR 3:7
P = 3 / (3 + 7) = 3/10 = 0.30
3. Odds 5:1 against → P = 1 / (5 + 1) = 1/6 = 0.1667
Bookmaker's note: quoted odds are always against, and they build in a margin, so the implied probabilities across all runners sum to slightly more than 1.
Q7: The birthday problem¶
In a room of k people, what is the probability that at least two share a birthday (ignore leap years)?
Compute it for k = 10, k = 23, and k = 50.
Solution
P(all different) = (365/365)(364/365)(363/365) … ((365−k+1)/365)
P(at least two share) = 1 − P(all different)
k = 10 → 1 − 0.8831 = 0.1169 (11.7%)
k = 23 → 1 − 0.4927 = 0.5073 (50.7%) ← the famous tipping point
k = 50 → 1 − 0.0296 = 0.9704 (97.0%)
bday <- function(k) 1 - prod((365 - 0:(k-1)) / 365)
sapply(c(10, 23, 50), bday) # 0.1169 0.5073 0.9704
def bday(k):
return 1 - np.prod([(365 - i) / 365 for i in range(k)])
[round(bday(k), 4) for k in (10, 23, 50)]
' Put k = 1..50 in A2:A51 and build the product recursively:
=B1*(365-A2+1)/365 ' B1 = 1 to start; then P(share) = 1 - B_k
Q8: Simulate a probability¶
Simulate 10,000 rolls of two dice and estimate P(sum = 7). Compare with the exact answer.
Solution
' A2: =RANDBETWEEN(1,6)+RANDBETWEEN(1,6) — fill down to A10001
=COUNTIF(A2:A10001, 7)/10000 ' ≈ 0.167
' Press F9 to re-randomize; the estimate moves by roughly ±0.008
' Exact: 6/36 = 0.16667
set.seed(1)
two <- sample(1:6, 10000, TRUE) + sample(1:6, 10000, TRUE)
mean(two == 7) # ≈ 0.167
6/36 # 0.16667 exact
# The Law of Large Numbers, visualised
running <- cumsum(two == 7) / seq_along(two)
plot(running, type = "l", ylim = c(0.10, 0.25), col = "#5B2A86",
xlab = "Rolls", ylab = "Running estimate of P(sum = 7)")
abline(h = 6/36, col = "#0FA3A3", lwd = 2, lty = 2)
rng = np.random.default_rng(1)
two = rng.integers(1, 7, 10_000) + rng.integers(1, 7, 10_000)
(two == 7).mean() # ≈ 0.167
What to notice: with 100 rolls the estimate wanders by ±0.05; with 10,000 it is stable to about ±0.008. Precision improves with √n, exactly as in 08-02.
Q9: Spot the fallacy¶
A roulette wheel has come up red eight times in a row. A gambler bets heavily on black, reasoning that black is "due".
What is wrong?
Solution
THE GAMBLER'S FALLACY.
Spins are INDEPENDENT. The wheel has no memory, so
P(black on spin 9) = 18/38 = 0.4737
regardless of the previous eight results.
What IS true: BEFORE any spins, P(eight reds in a row) = (18/38)^8 = 0.0025 —
a rare sequence. But once eight reds have happened, that probability is spent.
Conditioning on the past does not change an independent future event.
The Law of Large Numbers says the long-run PROPORTION approaches 18/38.
It does NOT say the counts "even out" — the absolute difference between
red and black counts actually tends to GROW with more spins.
⬅️ Previous: 04-02: Exercises — Measures of Position and Outliers ➡️ Next: 05-02: Exercises — Probability Rules and Conditional Probability