After completing this chapter, you will be able to:
Define and list the sample space for a given experiment
Express events using set notation and perform set operations (union, intersection, complement)
State and apply the three axioms of probability
Use De Morgan’s Laws and the addition rule to compute event probabilities
Compute probabilities using the sample-point method
Apply the mn counting rule to multi-stage experiments
Distinguish between permutations and combinations and apply each appropriately
Use the partitioning rule for dividing objects into distinct groups
Solve the Birthday Problem
Prerequisites: Chapter 1. Builds on: Variables, populations, relative frequency → probability.
Content current as of April 2026.
The Birthday Problem. How many people do you need in a room before there’s a better-than-even chance that at least two of them share a birthday?
Most people guess something around 180 — after all, there are 365 days in a year, so you’d need roughly half that many people. The actual answer is 23 . With just 23 people, the probability of at least one shared birthday exceeds 50%. With 50 people, it’s 97%. With 70 people, it’s 99.9%.
This result shocks nearly everyone who encounters it. But by the end of this chapter, you’ll have the tools to derive it yourself — using sample spaces, the axioms of probability, and counting methods.
1 Experiments, Sample Spaces, and Events ¶ What we’ll learn: The three foundational objects of probability — the experiment, the sample space, and the event — and how to express them precisely using set notation.
Why it matters: Before you can compute the probability of anything , you need to define what the possible outcomes are. A cybersecurity team monitoring network packets, a clinical trial testing a drug, a quality inspector checking parts — each is an experiment with a well-defined set of possible results. Getting the sample space right is the essential first step.
The real-life question: A cybersecurity team classifies each packet as normal (N), suspicious (S), or malicious (M). If they monitor three consecutive packets, how many different outcome sequences are possible? Which sequences represent “at least one malicious packet”?
Probability theory begins with a simple setup: something happens, and we observe the result.
An experiment is any process that produces an observable outcome that cannot be predicted with certainty.
The sample space S S S is the set of all possible outcomes.
An event is any subset of the sample space. An event A A A occurs if the observed outcome is in A A A .
A simple event (or sample point ) is an event containing exactly one outcome.
The Problem.
A cybersecurity system classifies each incoming packet as Normal (N), Suspicious (S), or Malicious (M). Three consecutive packets are monitored.
(a) List the sample space.
(b) List the event A A A = “at least one malicious packet.”
(c) List the event B B B = “all three packets have the same classification.”
(d) How many simple events are in S S S ?
Solution.
(a) Each packet has 3 classifications, and there are 3 packets:
S = { N N N , N N S , N N M , N S N , N S S , N S M , N M N , N M S , N M M , S = \{NNN, NNS, NNM, NSN, NSS, NSM, NMN, NMS, NMM, S = { NNN , NNS , NNM , NSN , NSS , NSM , NMN , NMS , NMM , S N N , S N S , S N M , S S N , S S S , S S M , S M N , S M S , S M M , SNN, SNS, SNM, SSN, SSS, SSM, SMN, SMS, SMM, SNN , SNS , SNM , SSN , SSS , SSM , SMN , SMS , SMM , M N N , M N S , M N M , M S N , M S S , M S M , M M N , M M S , M M M } MNN, MNS, MNM, MSN, MSS, MSM, MMN, MMS, MMM\} MNN , MNS , MNM , MSN , MSS , MSM , MMN , MMS , MMM } (b) A A A contains all outcomes with at least one M. It’s easier to find the complement: outcomes with no M are from { N , S } 3 \{N, S\}^3 { N , S } 3 , giving 2 3 = 8 2^3 = 8 2 3 = 8 outcomes. So ∣ A ∣ = 27 − 8 = 19 |A| = 27 - 8 = 19 ∣ A ∣ = 27 − 8 = 19 .
(c) B = { N N N , S S S , M M M } B = \{NNN, SSS, MMM\} B = { NNN , SSS , MMM } — 3 outcomes.
(d) ∣ S ∣ = 3 3 = 27 |S| = 3^3 = 27 ∣ S ∣ = 3 3 = 27 simple events.
In R.
classifications <- c("N", "S", "M")
S <- expand.grid(P1 = classifications, P2 = classifications, P3 = classifications)
nrow(S) # 27
# Event A: at least one M
A <- S[S$P1 == "M" | S$P2 == "M" | S$P3 == "M", ]
nrow(A) # 191.1 Set Operations ¶ Events are sets, and we manipulate them using three operations:
Union: A ∪ B A \cup B A ∪ B = “A A A or B B B or both” (at least one occurs)
Intersection: A ∩ B A \cap B A ∩ B = “A A A and B B B ” (both occur)
Complement: A ˉ \bar{A} A ˉ = “not A A A ” (A A A does not occur)
Mutually exclusive: A ∩ B = ∅ A \cap B = \emptyset A ∩ B = ∅ (cannot both occur)
The Problem.
A gasket can be defective in thickness (T T T ) or diameter (D D D ). From historical data: P ( T ) = 0.08 P(T) = 0.08 P ( T ) = 0.08 , P ( D ) = 0.05 P(D) = 0.05 P ( D ) = 0.05 , P ( T ∩ D ) = 0.02 P(T \cap D) = 0.02 P ( T ∩ D ) = 0.02 .
Find: (a) P ( T ∪ D ) P(T \cup D) P ( T ∪ D ) , (b) P ( T ∪ D ‾ ) P(\overline{T \cup D}) P ( T ∪ D ) , (c) P ( T ∩ D ˉ ) P(T \cap \bar{D}) P ( T ∩ D ˉ ) .
Solution.
(a) P ( T ∪ D ) = P ( T ) + P ( D ) − P ( T ∩ D ) = 0.08 + 0.05 − 0.02 = 0.11 P(T \cup D) = P(T) + P(D) - P(T \cap D) = 0.08 + 0.05 - 0.02 = 0.11 P ( T ∪ D ) = P ( T ) + P ( D ) − P ( T ∩ D ) = 0.08 + 0.05 − 0.02 = 0.11
(b) P ( T ∪ D ‾ ) = 1 − 0.11 = 0.89 P(\overline{T \cup D}) = 1 - 0.11 = 0.89 P ( T ∪ D ) = 1 − 0.11 = 0.89 (probability of no defect)
(c) P ( T ∩ D ˉ ) = P ( T ) − P ( T ∩ D ) = 0.08 − 0.02 = 0.06 P(T \cap \bar{D}) = P(T) - P(T \cap D) = 0.08 - 0.02 = 0.06 P ( T ∩ D ˉ ) = P ( T ) − P ( T ∩ D ) = 0.08 − 0.02 = 0.06 (thickness defect only)
The math: An experiment has a sample space S S S (all possible outcomes) and events (subsets of S S S ). We combine events with union (∪ \cup ∪ ), intersection (∩ \cap ∩ ), and complement (A ˉ \bar{A} A ˉ ). De Morgan’s Laws convert between unions and intersections.
In real life: The cybersecurity team’s 27-outcome sample space lets them express any scenario precisely. The gasket manufacturer knows 89% of products are defect-free — a number computed from set operations, not guesswork. These tools turn vague statements (“most gaskets are fine”) into exact quantities (“89% are defect-free, 6% have thickness defects only”).
Coming up: We’ve been using probability informally. What rules must probabilities obey? The answer: exactly three axioms.
2.1.1. A traffic light can be Red (R), Yellow (Y), or Green (G). Two consecutive lights are observed. (a) List S S S . (b) List A A A = “at least one red.” (c) List B B B = “both same color.” (d) Find A ∩ B A \cap B A ∩ B and A ∪ B A \cup B A ∪ B . (e) Are A A A and B B B mutually exclusive?
2.1.2. Let S = { 1 , 2 , . . . , 10 } S = \{1,2,...,10\} S = { 1 , 2 , ... , 10 } , A = { 2 , 4 , 6 , 8 , 10 } A = \{2,4,6,8,10\} A = { 2 , 4 , 6 , 8 , 10 } , B = { 1 , 2 , 3 , 4 , 5 } B = \{1,2,3,4,5\} B = { 1 , 2 , 3 , 4 , 5 } . Find A ∪ B A \cup B A ∪ B , A ∩ B A \cap B A ∩ B , A ˉ \bar{A} A ˉ , and verify De Morgan’s Laws for both A ∪ B ‾ \overline{A \cup B} A ∪ B and A ∩ B ‾ \overline{A \cap B} A ∩ B .
2.1.3. A circuit board can fail in soldering (S S S ) or wiring (W W W ). Given P ( S ) = 0.12 P(S) = 0.12 P ( S ) = 0.12 , P ( W ) = 0.07 P(W) = 0.07 P ( W ) = 0.07 , P ( S ∩ W ) = 0.03 P(S \cap W) = 0.03 P ( S ∩ W ) = 0.03 , find P ( S ∪ W ) P(S \cup W) P ( S ∪ W ) , P ( S ∪ W ‾ ) P(\overline{S \cup W}) P ( S ∪ W ) , P ( S ∩ W ˉ ) P(S \cap \bar{W}) P ( S ∩ W ˉ ) , and P ( S ˉ ∩ W ) P(\bar{S} \cap W) P ( S ˉ ∩ W ) .
2 The Axioms of Probability ¶ What we’ll learn: The three axioms — the foundational rules that every probability assignment must obey — and the key theorems that follow: the complement rule, the addition rule, and probability bounds.
Why it matters: Everything in Chapters 3–7 rests on these three axioms. They’re the minimal assumptions needed for a consistent theory of uncertainty.
The real-life question: A weather app says 40% chance of rain and 70% chance of clouds. Are these consistent? (Yes — rain implies clouds, so P ( rain ) ≤ P ( clouds ) P(\text{rain}) \leq P(\text{clouds}) P ( rain ) ≤ P ( clouds ) .) What if it said 80% rain and 90% sun? The axioms tell you when probability assignments are valid.
Let S S S be a sample space. A probability function P P P assigns a number P ( A ) P(A) P ( A ) to every event A A A such that:
Axiom 1: P ( A ) ≥ 0 P(A) \geq 0 P ( A ) ≥ 0 for every event A A A .
Axiom 2: P ( S ) = 1 P(S) = 1 P ( S ) = 1 .
Axiom 3: If A 1 , A 2 , A 3 , … A_1, A_2, A_3, \ldots A 1 , A 2 , A 3 , … are pairwise mutually exclusive, then P ( ⋃ i = 1 ∞ A i ) = ∑ i = 1 ∞ P ( A i ) P\left(\bigcup_{i=1}^{\infty} A_i\right) = \sum_{i=1}^{\infty} P(A_i) P ( ⋃ i = 1 ∞ A i ) = ∑ i = 1 ∞ P ( A i ) .
From these three axioms, we derive every other rule:
(a) P ( A ˉ ) = 1 − P ( A ) P(\bar{A}) = 1 - P(A) P ( A ˉ ) = 1 − P ( A ) (complement rule)
(b) P ( ∅ ) = 0 P(\emptyset) = 0 P ( ∅ ) = 0
(c) 0 ≤ P ( A ) ≤ 1 0 \leq P(A) \leq 1 0 ≤ P ( A ) ≤ 1 for all events A A A
(d) P ( A ∪ B ) = P ( A ) + P ( B ) − P ( A ∩ B ) P(A \cup B) = P(A) + P(B) - P(A \cap B) P ( A ∪ B ) = P ( A ) + P ( B ) − P ( A ∩ B ) (addition rule)
(e) If A ⊂ B A \subset B A ⊂ B , then P ( A ) ≤ P ( B ) P(A) \leq P(B) P ( A ) ≤ P ( B ) (monotonicity)
PROOF of (a): Complement Rule
Strategy: Write S as the union of A and its complement, then apply Axioms 2 and 3.
Since A A A and A ˉ \bar{A} A ˉ are mutually exclusive (an outcome cannot both be in A A A and not in A A A ) and A ∪ A ˉ = S A \cup \bar{A} = S A ∪ A ˉ = S (every outcome is either in A A A or not):
P ( S ) = P ( A ) + P ( A ˉ ) (Axiom 3, since A ∩ A ˉ = ∅ ) P(S) = P(A) + P(\bar{A}) \quad \text{(Axiom 3, since } A \cap \bar{A} = \emptyset\text{)} P ( S ) = P ( A ) + P ( A ˉ ) (Axiom 3, since A ∩ A ˉ = ∅ ) By Axiom 2, P ( S ) = 1 P(S) = 1 P ( S ) = 1 , so P ( A ˉ ) = 1 − P ( A ) P(\bar{A}) = 1 - P(A) P ( A ˉ ) = 1 − P ( A ) .
PROOF of (c): Probability Bounds — 0 ≤ P(A) ≤ 1
Strategy: The lower bound comes from Axiom 1; the upper bound from the complement rule and Axiom 1.
The lower bound P ( A ) ≥ 0 P(A) \geq 0 P ( A ) ≥ 0 is Axiom 1 directly.
For the upper bound: by part (a), P ( A ˉ ) = 1 − P ( A ) P(\bar{A}) = 1 - P(A) P ( A ˉ ) = 1 − P ( A ) . By Axiom 1, P ( A ˉ ) ≥ 0 P(\bar{A}) \geq 0 P ( A ˉ ) ≥ 0 , so 1 − P ( A ) ≥ 0 1 - P(A) \geq 0 1 − P ( A ) ≥ 0 , which gives P ( A ) ≤ 1 P(A) \leq 1 P ( A ) ≤ 1 .
Combining: 0 ≤ P ( A ) ≤ 1 0 \leq P(A) \leq 1 0 ≤ P ( A ) ≤ 1 for every event A A A .
PROOF of (d): General Addition Rule
Strategy: Decompose A ∪ B into three mutually exclusive “slices” — think of the three non-overlapping regions in a Venn diagram — then apply Axiom 3.
Any outcome in A ∪ B A \cup B A ∪ B falls into exactly one of three categories: (i) in A A A but not B B B , (ii) in both A A A and B B B , or (iii) in B B B but not A A A . In set notation:
A ∪ B = ( A ∩ B ˉ ) ∪ ( A ∩ B ) ∪ ( A ˉ ∩ B ) A \cup B = (A \cap \bar{B}) \cup (A \cap B) \cup (\bar{A} \cap B) A ∪ B = ( A ∩ B ˉ ) ∪ ( A ∩ B ) ∪ ( A ˉ ∩ B ) These three pieces are pairwise disjoint (an outcome can’t be in two of them simultaneously), so by Axiom 3:
P ( A ∪ B ) = P ( A ∩ B ˉ ) + P ( A ∩ B ) + P ( A ˉ ∩ B ) (*) P(A \cup B) = P(A \cap \bar{B}) + P(A \cap B) + P(\bar{A} \cap B) \tag{*} P ( A ∪ B ) = P ( A ∩ B ˉ ) + P ( A ∩ B ) + P ( A ˉ ∩ B ) ( * ) Now we express the first and third terms using quantities we know. Since A = ( A ∩ B ) ∪ ( A ∩ B ˉ ) A = (A \cap B) \cup (A \cap \bar{B}) A = ( A ∩ B ) ∪ ( A ∩ B ˉ ) and these two pieces are disjoint:
P ( A ) = P ( A ∩ B ) + P ( A ∩ B ˉ ) ⟹ P ( A ∩ B ˉ ) = P ( A ) − P ( A ∩ B ) P(A) = P(A \cap B) + P(A \cap \bar{B}) \quad \Longrightarrow \quad P(A \cap \bar{B}) = P(A) - P(A \cap B) P ( A ) = P ( A ∩ B ) + P ( A ∩ B ˉ ) ⟹ P ( A ∩ B ˉ ) = P ( A ) − P ( A ∩ B ) Similarly, P ( A ˉ ∩ B ) = P ( B ) − P ( A ∩ B ) P(\bar{A} \cap B) = P(B) - P(A \cap B) P ( A ˉ ∩ B ) = P ( B ) − P ( A ∩ B ) .
Substituting into (∗ * ∗ ):
P ( A ∪ B ) = [ P ( A ) − P ( A ∩ B ) ] + P ( A ∩ B ) + [ P ( B ) − P ( A ∩ B ) ] = P ( A ) + P ( B ) − P ( A ∩ B ) P(A \cup B) = [P(A) - P(A \cap B)] + P(A \cap B) + [P(B) - P(A \cap B)] = P(A) + P(B) - P(A \cap B) P ( A ∪ B ) = [ P ( A ) − P ( A ∩ B )] + P ( A ∩ B ) + [ P ( B ) − P ( A ∩ B )] = P ( A ) + P ( B ) − P ( A ∩ B ) PROOF of (e): Monotonicity — If A ⊂ B, then P(A) ≤ P(B)
Strategy: Write B as the disjoint union of A and the “extra” part B ∩ Ā.
If A ⊂ B A \subset B A ⊂ B , then B = A ∪ ( B ∩ A ˉ ) B = A \cup (B \cap \bar{A}) B = A ∪ ( B ∩ A ˉ ) , and these two pieces are disjoint (since A A A and A ˉ \bar{A} A ˉ don’t overlap). By Axiom 3:
P ( B ) = P ( A ) + P ( B ∩ A ˉ ) P(B) = P(A) + P(B \cap \bar{A}) P ( B ) = P ( A ) + P ( B ∩ A ˉ ) By Axiom 1, P ( B ∩ A ˉ ) ≥ 0 P(B \cap \bar{A}) \geq 0 P ( B ∩ A ˉ ) ≥ 0 , so P ( B ) ≥ P ( A ) P(B) \geq P(A) P ( B ) ≥ P ( A ) , i.e., P ( A ) ≤ P ( B ) P(A) \leq P(B) P ( A ) ≤ P ( B ) .
Adding probabilities without subtracting the overlap. P ( A ∪ B ) = P ( A ) + P ( B ) P(A \cup B) = P(A) + P(B) P ( A ∪ B ) = P ( A ) + P ( B ) is ONLY correct when A A A and B B B are mutually exclusive. In general, subtract P ( A ∩ B ) P(A \cap B) P ( A ∩ B ) .
Confusing “mutually exclusive” with “independent.” Mutually exclusive: A ∩ B = ∅ A \cap B = \emptyset A ∩ B = ∅ . Independent: P ( A ∩ B ) = P ( A ) P ( B ) P(A \cap B) = P(A)P(B) P ( A ∩ B ) = P ( A ) P ( B ) . These are different concepts (Chapter 3).
Assuming P ( A ˉ ) = P ( A ) P(\bar{A}) = P(A) P ( A ˉ ) = P ( A ) . Only true when P ( A ) = 0.5 P(A) = 0.5 P ( A ) = 0.5 .
The math: Three axioms (non-negativity, normalization, additivity for disjoint events) generate all of probability theory. The complement rule and general addition rule are the two most-used consequences.
In real life: The weather app question is now decidable. The axioms give you a consistency checker: any probability assignment that violates 0 ≤ P ( A ) ≤ 1 0 \leq P(A) \leq 1 0 ≤ P ( A ) ≤ 1 , or P ( A ) + P ( A ˉ ) ≠ 1 P(A) + P(\bar{A}) \neq 1 P ( A ) + P ( A ˉ ) = 1 , or double-counts overlapping events, is wrong . A student who claims P ( A ) = 0.7 P(A) = 0.7 P ( A ) = 0.7 , P ( B ) = 0.6 P(B) = 0.6 P ( B ) = 0.6 , P ( A ∩ B ) = 0.1 P(A \cap B) = 0.1 P ( A ∩ B ) = 0.1 has made an error — because P ( A ∪ B ) = 1.2 > 1 P(A \cup B) = 1.2 > 1 P ( A ∪ B ) = 1.2 > 1 , violating Theorem 2.2(c).
Coming up: The axioms tell us what rules probabilities obey. The sample-point method tells us how to compute them.
2.2.1. Prove P ( ∅ ) = 0 P(\emptyset) = 0 P ( ∅ ) = 0 using S = S ∪ ∅ S = S \cup \emptyset S = S ∪ ∅ and the axioms.
2.2.2. Given P ( A ) = 0.6 P(A) = 0.6 P ( A ) = 0.6 , P ( B ) = 0.4 P(B) = 0.4 P ( B ) = 0.4 , P ( A ∩ B ) = 0.2 P(A \cap B) = 0.2 P ( A ∩ B ) = 0.2 : find P ( A ∪ B ) P(A \cup B) P ( A ∪ B ) , P ( A ˉ ) P(\bar{A}) P ( A ˉ ) , P ( A ˉ ∩ B ˉ ) P(\bar{A} \cap \bar{B}) P ( A ˉ ∩ B ˉ ) , P ( A ∩ B ˉ ) P(A \cap \bar{B}) P ( A ∩ B ˉ ) .
2.2.3. Events C C C and D D D are mutually exclusive with P ( C ) = 0.35 P(C) = 0.35 P ( C ) = 0.35 , P ( D ) = 0.25 P(D) = 0.25 P ( D ) = 0.25 . Find P ( C ∪ D ) P(C \cup D) P ( C ∪ D ) and P ( C ∪ D ‾ ) P(\overline{C \cup D}) P ( C ∪ D ) .
2.2.4. Show that P ( A ) = 0.7 P(A) = 0.7 P ( A ) = 0.7 , P ( B ) = 0.6 P(B) = 0.6 P ( B ) = 0.6 , P ( A ∩ B ) = 0.1 P(A \cap B) = 0.1 P ( A ∩ B ) = 0.1 is inconsistent.
2.2.5. Prove: if A ⊂ B A \subset B A ⊂ B , then P ( A ) ≤ P ( B ) P(A) \leq P(B) P ( A ) ≤ P ( B ) . (Hint: B = A ∪ ( B ∩ A ˉ ) B = A \cup (B \cap \bar{A}) B = A ∪ ( B ∩ A ˉ ) .)
3 The Sample-Point Method ¶ What we’ll learn: A systematic 3-step method for computing probabilities: list sample points, assign probabilities, sum over the event.
Why it matters: This method converts every probability question into a counting question — which is why we need the counting tools that follow.
The real-life question: Two fair dice are rolled. What’s the probability the sum is 7?
Step 1: List the sample points in S S S .
Step 2: Assign probabilities to each (summing to 1).
Step 3: P ( A ) = ∑ E i ∈ A P ( E i ) P(A) = \sum_{E_i \in A} P(E_i) P ( A ) = ∑ E i ∈ A P ( E i ) .
When all outcomes are equally likely: P ( A ) = ∣ A ∣ / ∣ S ∣ P(A) = |A|/|S| P ( A ) = ∣ A ∣/∣ S ∣ .
Solution.
S = { ( i , j ) : i , j ∈ { 1 , . . . , 6 } } S = \{(i,j) : i,j \in \{1,...,6\}\} S = {( i , j ) : i , j ∈ { 1 , ... , 6 }} , so ∣ S ∣ = 36 |S| = 36 ∣ S ∣ = 36 . All equally likely.
A = "sum = 7" = { ( 1 , 6 ) , ( 2 , 5 ) , ( 3 , 4 ) , ( 4 , 3 ) , ( 5 , 2 ) , ( 6 , 1 ) } A = \text{"sum = 7"} = \{(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)\} A = "sum = 7" = {( 1 , 6 ) , ( 2 , 5 ) , ( 3 , 4 ) , ( 4 , 3 ) , ( 5 , 2 ) , ( 6 , 1 )} , so ∣ A ∣ = 6 |A| = 6 ∣ A ∣ = 6 .
P ( A ) = 6 36 = 1 6 ≈ 0.167 P(A) = \frac{6}{36} = \frac{1}{6} \approx 0.167 P ( A ) = 36 6 = 6 1 ≈ 0.167 set.seed(123)
die1 <- sample(1:6, 100000, replace = TRUE)
die2 <- sample(1:6, 100000, replace = TRUE)
mean(die1 + die2 == 7) # ≈ 0.1667The math: P ( A ) = ∣ A ∣ / ∣ S ∣ P(A) = |A|/|S| P ( A ) = ∣ A ∣/∣ S ∣ when outcomes are equally likely. This converts probability into counting.
In real life: Dice, cards, lotteries, random selections — any experiment with equally likely outcomes reduces to: count what you want, divide by the total. But counting gets hard fast. With two dice there are only 36 outcomes. With a poker hand there are 2,598,960. We need systematic counting tools.
2.3.1. Two fair coins are tossed. Find P ( exactly one head ) P(\text{exactly one head}) P ( exactly one head ) , P ( at least one head ) P(\text{at least one head}) P ( at least one head ) , P ( no heads ) P(\text{no heads}) P ( no heads ) .
2.3.2. An urn has 3 red, 4 blue, 5 green marbles. One is drawn at random. Find P ( red ) P(\text{red}) P ( red ) , P ( not green ) P(\text{not green}) P ( not green ) .
2.3.3. A loaded die has P ( 6 ) = 0.25 P(6) = 0.25 P ( 6 ) = 0.25 and all other faces equally likely. Find P ( even ) P(\text{even}) P ( even ) .
What we’ll learn: The multiplication principle — if one task has m m m outcomes and a second has n n n , together they have m × n m \times n m × n outcomes.
Why it matters: A restaurant menu with 4 appetizers, 6 entrees, and 3 desserts offers 4 × 6 × 3 = 72 4 \times 6 \times 3 = 72 4 × 6 × 3 = 72 meals. A state issuing license plates with 3 letters and 4 digits has 2 6 3 × 1 0 4 = 175 , 760 , 000 26^3 \times 10^4 = 175{,}760{,}000 2 6 3 × 1 0 4 = 175 , 760 , 000 possible plates. Choices multiply.
The real-life question: How many distinct license plates are possible with 3 letters followed by 4 digits?
If an experiment has k k k stages with n 1 , n 2 , … , n k n_1, n_2, \ldots, n_k n 1 , n 2 , … , n k outcomes respectively, the total number of outcomes is n 1 × n 2 × ⋯ × n k n_1 \times n_2 \times \cdots \times n_k n 1 × n 2 × ⋯ × n k .
Solution.
(a) With repetition: We identify each character position as a stage:
Stage Description Choices 1 First letter 26 2 Second letter 26 3 Third letter 26 4 First digit 10 5 Second digit 10 6 Third digit 10 7 Fourth digit 10
By the mn rule: 26 × 26 × 26 × 10 × 10 × 10 × 10 = 2 6 3 × 1 0 4 = 175 , 760 , 000 26 \times 26 \times 26 \times 10 \times 10 \times 10 \times 10 = 26^3 \times 10^4 = 175{,}760{,}000 26 × 26 × 26 × 10 × 10 × 10 × 10 = 2 6 3 × 1 0 4 = 175 , 760 , 000
(b) Without repetition: Each letter/digit used is no longer available for the next stage:
Letters: 26 × 25 × 24 = 15 , 600 26 \times 25 \times 24 = 15{,}600 26 × 25 × 24 = 15 , 600
Digits: 10 × 9 × 8 × 7 = 5 , 040 10 \times 9 \times 8 \times 7 = 5{,}040 10 × 9 × 8 × 7 = 5 , 040
Total: 15 , 600 × 5 , 040 = 78 , 624 , 000 15{,}600 \times 5{,}040 = 78{,}624{,}000 15 , 600 × 5 , 040 = 78 , 624 , 000
The math: Choices at independent stages multiply: m × n m \times n m × n total outcomes for two stages. This is the foundation of all counting.
In real life: The state needs to know whether 175.8 million plates is enough for its vehicle population. A 4-digit PIN has 1 0 4 = 10 , 000 10^4 = 10{,}000 1 0 4 = 10 , 000 possibilities, so a thief has a 1 / 10 , 000 = 0.01 % 1/10{,}000 = 0.01\% 1/10 , 000 = 0.01% chance of guessing on the first try. The mn rule answers operational security questions.
2.4.1. A 4-digit PIN allows digits 0–9 with repetition. (a) How many PINs? (b) Without repetition? (c) P ( correct guess on first try ) P(\text{correct guess on first try}) P ( correct guess on first try ) ?
2.4.2. A binary string of length 10 has how many possibilities? How many start with “111”?
2.4.3. A researcher assigns each of 8 patients to one of 3 treatment groups. How many assignments?
5 Permutations ¶ What we’ll learn: How to count ordered arrangements — selecting r r r objects from n n n when order matters .
Why it matters: A coach selecting a batting order, a company assigning ranked positions, a DJ ordering songs — all require permutations because sequence changes the outcome .
The real-life question: A DJ has 20 songs but time for only 5. How many set lists are possible?
Why it works: Position 1 has n n n choices, position 2 has n − 1 n-1 n − 1 , ..., position r r r has n − r + 1 n-r+1 n − r + 1 . By the mn rule: n ( n − 1 ) ⋯ ( n − r + 1 ) n(n-1)\cdots(n-r+1) n ( n − 1 ) ⋯ ( n − r + 1 ) .
The Problem.
A track meet has 12 runners in a race. In how many ways can the gold, silver, and bronze medals be awarded (no ties)?
Solution.
We are selecting 3 runners from 12 and the order matters — gold is different from silver. This is a permutation:
12 P 3 = 12 ! 9 ! = 12 × 11 × 10 = 1 , 320 _{12}P_3 = \frac{12!}{9!} = 12 \times 11 \times 10 = 1{,}320 12 P 3 = 9 ! 12 ! = 12 × 11 × 10 = 1 , 320 Note: if we only cared about which 3 runners medal (not who gets gold vs. silver vs. bronze), we’d use the combination ( 12 3 ) = 220 \binom{12}{3} = 220 ( 3 12 ) = 220 , which is exactly 12 P 3 / 3 ! = 1320 / 6 = 220 _{12}P_3 / 3! = 1320/6 = 220 12 P 3 /3 ! = 1320/6 = 220 . The factor of 3 ! = 6 3! = 6 3 ! = 6 is the number of ways to arrange 3 people in order — the permutation counts each of these arrangements separately, the combination doesn’t.
5.1 When to Use Permutations vs. Combinations ¶ This is the single most common source of counting errors. Use this checklist:
Ask: “If I swap two of the selected objects, do I get a different outcome?”
Yes → Permutation n P r _nP_r n P r . (Positions, rankings, sequences, passwords, arrangements)
No → Combination ( n r ) \binom{n}{r} ( r n ) . (Teams, committees, groups, subsets, hands of cards)
Examples:
Selecting a President, VP, and Treasurer from 10 candidates → Permutation (swapping President and VP changes the outcome).
Selecting 3 committee members from 10 candidates → Combination (swapping two members gives the same committee).
The math: n P r = n ! / ( n − r ) ! _nP_r = n!/(n-r)! n P r = n ! / ( n − r )! counts ordered selections. Order matters: playing Song A first and Song B second is a different experience than the reverse.
In real life: A race with 12 runners has 12 P 3 = 1 , 320 _{12}P_3 = 1{,}320 12 P 3 = 1 , 320 possible podium finishes (1st/2nd/3rd). A company interviewing 8 candidates for President, VP, and Secretary has 8 P 3 = 336 _{8}P_3 = 336 8 P 3 = 336 possible leadership teams. If order didn’t matter, we’d need combinations instead.
2.5.1. Compute 7 P 3 _7P_3 7 P 3 , 5 P 5 _5P_5 5 P 5 , 10 P 1 _{10}P_1 10 P 1 , n P 0 _nP_0 n P 0 .
2.5.2. 12 runners in a race. How many outcomes for 1st, 2nd, 3rd?
2.5.3. How many 4-letter “words” from 26 letters (no repeats)?
6 Combinations and Partitions ¶ What we’ll learn: How to count unordered selections (r r r from n n n , order doesn’t matter) and how to partition n n n objects into k k k groups.
Why it matters: Most real selections are about groups , not sequences . Hiring 3 finalists from 12, selecting a jury of 12 from 30, dealing a poker hand — these are combinations because the order of selection is irrelevant.
The real-life question: A jury of 12 from 30 eligible citizens. How many possible juries?
Why it works: n P r _nP_r n P r counts ordered arrangements. Each group of r r r objects appears in r ! r! r ! different orders. Dividing removes the redundancy: ( n r ) = n P r r ! \binom{n}{r} = \frac{_nP_r}{r!} ( r n ) = r ! n P r .
The Problem.
An inspector selects 4 items from a shipment of 20 (5 defective, 15 good). What’s the probability exactly 2 are defective?
Solution.
∣ S ∣ = ( 20 4 ) = 4 , 845 |S| = \binom{20}{4} = 4{,}845 ∣ S ∣ = ( 4 20 ) = 4 , 845 . Choose 2 defective from 5: ( 5 2 ) = 10 \binom{5}{2} = 10 ( 2 5 ) = 10 . Choose 2 good from 15: ( 15 2 ) = 105 \binom{15}{2} = 105 ( 2 15 ) = 105 .
P ( exactly 2 defective ) = ( 5 2 ) ( 15 2 ) ( 20 4 ) = 10 × 105 4 , 845 = 1 , 050 4 , 845 ≈ 0.2167 P(\text{exactly 2 defective}) = \frac{\binom{5}{2}\binom{15}{2}}{\binom{20}{4}} = \frac{10 \times 105}{4{,}845} = \frac{1{,}050}{4{,}845} \approx 0.2167 P ( exactly 2 defective ) = ( 4 20 ) ( 2 5 ) ( 2 15 ) = 4 , 845 10 × 105 = 4 , 845 1 , 050 ≈ 0.2167 choose(5, 2) * choose(15, 2) / choose(20, 4) # 0.2167The number of ways to partition n n n distinct objects into k k k groups of sizes n 1 , n 2 , … , n k n_1, n_2, \ldots, n_k n 1 , n 2 , … , n k (∑ n i = n \sum n_i = n ∑ n i = n ):
n ! n 1 ! ⋅ n 2 ! ⋯ n k ! \frac{n!}{n_1! \cdot n_2! \cdots n_k!} n 1 ! ⋅ n 2 ! ⋯ n k ! n ! Using permutations when combinations are needed. Ask: “Does order matter?” Selecting committee members : combinations. Selecting President, VP, Secretary : permutations.
Adding instead of multiplying across stages. In Example 2.6: ( 5 2 ) × ( 15 2 ) \binom{5}{2} \times \binom{15}{2} ( 2 5 ) × ( 2 15 ) , NOT ( 5 2 ) + ( 15 2 ) \binom{5}{2} + \binom{15}{2} ( 2 5 ) + ( 2 15 ) .
Confusing ( n r ) \binom{n}{r} ( r n ) with n P r _nP_r n P r . Remember: ( n r ) = n P r / r ! \binom{n}{r} = _nP_r / r! ( r n ) = n P r / r ! . Combinations are always ≤ \leq ≤ permutations.
The math: ( n r ) = n ! / [ r ! ( n − r ) ! ] \binom{n}{r} = n!/[r!(n-r)!] ( r n ) = n ! / [ r ! ( n − r )!] for unordered selections. The partitioning rule n ! / ( n 1 ! ⋯ n k ! ) n!/(n_1! \cdots n_k!) n ! / ( n 1 ! ⋯ n k !) generalizes to k k k groups. Combined with P ( A ) = ∣ A ∣ / ∣ S ∣ P(A) = |A|/|S| P ( A ) = ∣ A ∣/∣ S ∣ , these solve most combinatorial probability problems.
In real life: The inspector has a 21.7% chance of finding exactly 2 defectives in 4 items. The jury pool of 30 yields ( 30 12 ) = 86 , 493 , 225 \binom{30}{12} = 86{,}493{,}225 ( 12 30 ) = 86 , 493 , 225 possible juries. The clinical trial has 17 million possible random assignments. These exact numbers — not estimates — drive real decisions.
2.6.1. Compute ( 8 3 ) \binom{8}{3} ( 3 8 ) , ( 10 10 ) \binom{10}{10} ( 10 10 ) , ( n 0 ) \binom{n}{0} ( 0 n ) , ( n 1 ) \binom{n}{1} ( 1 n ) .
2.6.2. A committee of 5 from 8 men and 6 women. How many committees with: (a) no restrictions? (b) exactly 3 women? (c) at least 1 woman?
2.6.3. A bag has 7 red, 5 blue marbles. Draw 3 without replacement. Find P ( all red ) P(\text{all red}) P ( all red ) , P ( exactly 1 blue ) P(\text{exactly 1 blue}) P ( exactly 1 blue ) , P ( at least 1 blue ) P(\text{at least 1 blue}) P ( at least 1 blue ) .
2.6.4. 15 students divided into 3 project teams of 5. How many assignments?
2.6.5. Prove ( n r ) = ( n n − r ) \binom{n}{r} = \binom{n}{n-r} ( r n ) = ( n − r n ) algebraically and give an intuitive “story” explanation.
7 Putting It All Together: The Birthday Problem ¶ What we’ll learn: We solve the Birthday Problem from the chapter opener using the complement rule, the mn rule, and permutations — combining everything from this chapter.
Why it matters: This demonstrates the complement method, one of the most powerful strategies in probability: instead of counting what you want, count what you don’t want and subtract from 1.
The real-life question: In a class of 30 students, what’s the probability at least two share a birthday?
The complement strategy: Computing “at least one match” directly is a nightmare. Instead:
P ( at least one match ) = 1 − P ( all birthdays different ) P(\text{at least one match}) = 1 - P(\text{all birthdays different}) P ( at least one match ) = 1 − P ( all birthdays different ) Assumptions: 365 days, all equally likely, independence.
Computing P(\text{all n birthdays different}) :
Person 1: any day (365 / 365 365/365 365/365 ). Person 2 must avoid Person 1’s birthday: 364 / 365 364/365 364/365 . Person 3: 363 / 365 363/365 363/365 . Person k k k : ( 365 − k + 1 ) / 365 (365-k+1)/365 ( 365 − k + 1 ) /365 .
We can multiply these fractions because we assumed birthdays are independent — knowing Person 1’s birthday doesn’t affect the probability of Person 2’s birthday. (This is the mn rule in action: each person’s birthday is a “stage” with outcomes that don’t depend on previous stages.)
P ( no match ) = 365 365 ⋅ 364 365 ⋯ 365 − n + 1 365 = 365 P n 36 5 n P(\text{no match}) = \frac{365}{365} \cdot \frac{364}{365} \cdots \frac{365-n+1}{365} = \frac{_{365}P_n}{365^n} P ( no match ) = 365 365 ⋅ 365 364 ⋯ 365 365 − n + 1 = 36 5 n 365 P n P ( at least one match among n people ) = 1 − 365 P n 36 5 n \boxed{P(\text{at least one match among } n \text{ people}) = 1 - \frac{_{365}P_n}{365^n}} P ( at least one match among n people ) = 1 − 36 5 n 365 P n n n n P ( match ) P(\text{match}) P ( match ) 10 0.117 23 0.507 30 0.706 50 0.970 57 0.990
birthday_prob <- function(n) {
1 - prod((365:(365 - n + 1)) / 365)
}
n_vals <- 1:80
plot(n_vals, sapply(n_vals, birthday_prob), type = "l", lwd = 2,
col = "steelblue", xlab = "People", ylab = "P(match)",
main = "The Birthday Problem")
abline(h = 0.5, v = 23, lty = 2, col = "red")Why so low? With n n n people, there are ( n 2 ) \binom{n}{2} ( 2 n ) pairs. At n = 23 n = 23 n = 23 : ( 23 2 ) = 253 \binom{23}{2} = 253 ( 2 23 ) = 253 pairs — each a potential match. The quadratic growth of pairs compensates for the low probability of any single match.
The math: The Birthday Problem combines complements, the mn rule, and permutations. The answer (n = 23 n = 23 n = 23 for 50%) follows from the complement formula 1 − 365 P n / 36 5 n 1 - _{365}P_n / 365^n 1 − 365 P n /36 5 n .
In real life: This isn’t just a party trick. The birthday attack in cryptography exploits the same math: a hash function with d d d -bit output can be broken in ≈ 2 d / 2 \approx 2^{d/2} ≈ 2 d /2 attempts, far fewer than the 2 d 2^d 2 d brute force requires. This is why cryptographic hash lengths must be very large. The Birthday Problem determines digital security standards.
Experiment / Sample Space / Event: An experiment produces outcomes in S S S . Events are subsets of S S S .
Set operations: A ∪ B A \cup B A ∪ B (or), A ∩ B A \cap B A ∩ B (and), A ˉ \bar{A} A ˉ (not). De Morgan’s Laws: A ∪ B ‾ = A ˉ ∩ B ˉ \overline{A \cup B} = \bar{A} \cap \bar{B} A ∪ B = A ˉ ∩ B ˉ .
Three axioms: P ( A ) ≥ 0 P(A) \geq 0 P ( A ) ≥ 0 ; P ( S ) = 1 P(S) = 1 P ( S ) = 1 ; disjoint events add.
Complement rule: P ( A ˉ ) = 1 − P ( A ) P(\bar{A}) = 1 - P(A) P ( A ˉ ) = 1 − P ( A ) . Addition rule: P ( A ∪ B ) = P ( A ) + P ( B ) − P ( A ∩ B ) P(A \cup B) = P(A) + P(B) - P(A \cap B) P ( A ∪ B ) = P ( A ) + P ( B ) − P ( A ∩ B ) .
Sample-point method: P ( A ) = ∣ A ∣ / ∣ S ∣ P(A) = |A|/|S| P ( A ) = ∣ A ∣/∣ S ∣ when equally likely.
mn rule: stages multiply: n 1 × n 2 × ⋯ × n k n_1 \times n_2 \times \cdots \times n_k n 1 × n 2 × ⋯ × n k .
Permutations: n P r = n ! / ( n − r ) ! _nP_r = n!/(n-r)! n P r = n ! / ( n − r )! (order matters).
Combinations: ( n r ) = n ! / [ r ! ( n − r ) ! ] \binom{n}{r} = n!/[r!(n-r)!] ( r n ) = n ! / [ r ! ( n − r )!] (order doesn’t matter).
Partitions: n ! / ( n 1 ! ⋯ n k ! ) n!/(n_1! \cdots n_k!) n ! / ( n 1 ! ⋯ n k !) for dividing into groups.
Birthday Problem: 1 − 365 P n / 36 5 n 1 - _{365}P_n / 365^n 1 − 365 P n /36 5 n . Only 23 people for 50%.
Every probability calculation in this chapter assumed we knew the sample space and the probabilities of each outcome. But here’s the uncomfortable truth: in real life, you almost never know the true probabilities.
When we said the die was “fair,” we assumed P ( i ) = 1 / 6 P(i) = 1/6 P ( i ) = 1/6 . When we said birthdays were “equally likely,” we assumed a uniform distribution over 365 days. These are models — simplifications of reality. Real dice are slightly unbalanced. Real birthdays cluster in September.
How sensitive are our answers to these assumptions? If birthdays are not equally likely, does the Birthday Problem answer change? (Yes — it actually gets more likely to have a match.) If the die is slightly loaded, does P ( sum = 7 ) P(\text{sum} = 7) P ( sum = 7 ) change? (Yes, but by how much?) Learning to question your model is as important as learning to compute within it.
8 Chapter 2 Refresh Homework ¶ These problems integrate material across all sections of Chapter 2.
R2.1. A company selects a team of 3 from 10 engineers, then designates one as leader. (a) How many teams? (b) How many leaders per team? (c) Total (team + leader) outcomes? (d) Verify by computing: pick leader first, then 2 others.
R2.2. An alarm system has 3 sensors, each detecting an intruder (D) 90% of the time or failing (F) 10%. (a) List S S S . (b) Are outcomes equally likely? (c) List A A A = “at least 2 detect.” (d) Compute P ( A ) P(A) P ( A ) by assigning probabilities (P ( D D F ) = 0. 9 2 × 0.1 P(DDF) = 0.9^2 \times 0.1 P ( DD F ) = 0. 9 2 × 0.1 ). (e) Verify using the complement.
R2.3. A club has 9 seniors and 6 juniors. A committee of 4 is formed at random. Find: (a) total committees, (b) committees with exactly 2 seniors and 2 juniors, (c) P ( exactly 2 seniors, 2 juniors ) P(\text{exactly 2 seniors, 2 juniors}) P ( exactly 2 seniors, 2 juniors ) , (d) P ( at least 1 junior ) P(\text{at least 1 junior}) P ( at least 1 junior ) using the complement.
R2.4. Passwords are 8 characters (26 lowercase + 26 uppercase + 10 digits). (a) Total passwords? (b) Lowercase-only passwords? (c) P ( random password is all lowercase ) P(\text{random password is all lowercase}) P ( random password is all lowercase ) ? (d) Why does this matter for security?
R2.5. Use R to compute the exact birthday probability for n = 40 n = 40 n = 40 , then simulate: generate 40 random birthdays 100,000 times and count matches. Compare.
R2.6. Three events satisfy: P ( A ) = 0.4 P(A) = 0.4 P ( A ) = 0.4 , P ( B ) = 0.3 P(B) = 0.3 P ( B ) = 0.3 , P ( C ) = 0.2 P(C) = 0.2 P ( C ) = 0.2 , P ( A ∩ B ) = 0.15 P(A \cap B) = 0.15 P ( A ∩ B ) = 0.15 , P ( A ∩ C ) = 0.08 P(A \cap C) = 0.08 P ( A ∩ C ) = 0.08 , P ( B ∩ C ) = 0.06 P(B \cap C) = 0.06 P ( B ∩ C ) = 0.06 , P ( A ∩ B ∩ C ) = 0.02 P(A \cap B \cap C) = 0.02 P ( A ∩ B ∩ C ) = 0.02 . Find P ( A ∪ B ∪ C ) P(A \cup B \cup C) P ( A ∪ B ∪ C ) using inclusion-exclusion, and P ( A ∪ B ∪ C ‾ ) P(\overline{A \cup B \cup C}) P ( A ∪ B ∪ C ) .
9 Chapter 2 Quiz ¶ Test your understanding. You need 80% (12/15) to earn the badge.