Scroll to turn the page
Probability · Probability (college)
probability as counting
How many people must be in a room before it is more likely than not that two of them share a birthday? With 365 days to go round, the answer is only 23.
The curve in the figure is that probability, worked out exactly for every room size from 1 to 60. It passes 1/2 at n = 23 (0.5073) and 0.99 at n = 57. The ring is one year, and the balls are a room of 23 people on their birthdays.
Intuition fails because the question is not about any one person. 23 people make 253 pairs, and each pair is a chance for a match.
This chapter builds probability from the ground up. It starts with the sample space and three axioms. When outcomes are equally likely, probability becomes counting, so the rest of the chapter is about counting well: the multiplication rule, permutations and combinations, inclusion–exclusion, and stars and bars.
This subject is the core of a first university course in probability, the kind taken after a year of calculus by students of mathematics, statistics, engineering, computer science and economics.
what probability is, in three rules
An experiment’s sample space S is the set of all its possible outcomes. An event is a subset of S. A probability function P assigns each event a number.
Toss a coin three times. S has 2 × 2 × 2 = 8 outcomes, from HHH to TTT. The event A, “at least two heads”, is the subset {HHH, HHT, HTH, THH}. The event B, “the first toss is heads”, is {HHH, HHT, HTH, HTT}.
Since events are sets, the language of sets is the language of events. A ∪ B (“A or B”) happens if at least one does; A ∩ B (“A and B”) if both do; Ac if A does not.
The axioms. In 1933 Andrey Kolmogorov showed that all of probability follows from three rules:
Everything else is a consequence. A and Ac are disjoint and fill S, so P(Ac) = 1 − P(A). If A ⊆ B, then P(A) ≤ P(B). Splitting A ∪ B into disjoint pieces gives the addition rule:
The overlap HHH, HHT, HTH is counted once in P(A) and again in P(B), so it is subtracted once. In the figure the eight outcomes sit in their regions: 5 of them lie in A or B.
when every outcome is equally likely
If S is finite and every outcome is equally likely, then the probability of an event is the fraction of outcomes in it:
This is the naive definition. It is how probability began: in 1654 Blaise Pascal and Pierre de Fermat worked out gamblers’ questions by counting equally likely outcomes. It needs symmetry, so it fails for a biased coin or for “will it rain tomorrow”, where outcomes are not equally likely.
The multiplication rule. If an experiment has stages, and stage 1 has n1 outcomes, then for each of them stage 2 has n2, and so on, the whole experiment has n1n2⋯ outcomes.
Choosing an outfit from 3 shirts, 4 pairs of pants and 2 pairs of shoes is a tree with 3 × 4 × 2 = 24 leaves, one per outfit. Each path from the root is one outfit; the red one walks through all of them.
The stages need not be independent; only the number of choices at each stage must not depend on earlier choices. The three tosses in 1.1 are a tree with 2 × 2 × 2 = 8 leaves.
Sampling with replacement. Choosing k times from n objects, with replacement and in order, gives nk outcomes. A 4-digit PIN has 104 = 10,000 possibilities, so a guess is right with probability 1/10,000.
order matters, or it doesn’t
Choosing k of n distinct objects without replacement, there are n(n − 1)⋯(n − k + 1) ordered lists, and C(n, k) unordered sets:
Every set of k can be put in order in k! ways, so dividing the ordered count by k! counts each set once. From 10 people, a president, vice president and treasurer can be chosen in 10 × 9 × 8 = 720 ways; a committee of 3, where order doesn’t matter, in 720/3! = 120 ways.
| order matters | order doesn’t | |
|---|---|---|
| with replacement | nk | C(n + k − 1, k) (1.6) |
| without replacement | n!/(n − k)! | C(n, k) |
Pascal’s triangle. Row n lists C(n, 0) to C(n, n), and each number is the two above it, added. A story proof says why: to choose k of 8 people, either person 8 is chosen (choose k − 1 more from the other 7) or not (choose all k from the 7). So C(8, k) = C(7, k − 1) + C(7, k). Row 8 adds to 28 = 256, the number of subsets of 8 people.
Example: a full house. A poker hand is 5 of 52 cards, all C(52, 5) = 2,598,960 hands equally likely. A full house is three of one rank and two of another: choose the rank of the three (13), which three of its 4 suits (C(4, 3) = 4), the rank of the pair (12 left) and its two suits (C(4, 2) = 6):
the complement, and a product
In a room of n people, what is the probability that at least two share a birthday? Take 365 equally likely birthdays and ignore February 29.
“At least one match” has many cases. Its complement, “all different”, has one, so count that. The first person can have any of 365 days, the second any of the other 364, and so on (the multiplication rule):
So P(at least one match) = 1 − P(no match). For n = 23 it is 0.5073, just over 1/2. For n = 30 it is 0.706, and for n = 50, 0.970. With 366 people a match is certain, by the pigeonhole principle.
| n | 10 | 20 | 23 | 30 | 40 | 50 | 57 |
|---|---|---|---|---|---|---|---|
| P(match) | 0.117 | 0.411 | 0.507 | 0.706 | 0.891 | 0.970 | 0.990 |
Why so few? The count that matters is pairs, and C(n, 2) grows like n2. 23 people form C(23, 2) = 253 pairs, each matching with probability 1/365.
Check by simulation. In 1,000 random rooms of 23, 522 had a shared birthday: 0.522, close to the exact 0.507.
Real birthdays are not quite uniform (some times of year have more births than others). That only makes a match more likely: the uniform distribution gives the smallest chance of a match.
add, subtract the overlaps, add back
For two events, P(A ∪ B) = P(A) + P(B) − P(A ∩ B). For n events, inclusion–exclusion alternates: add the singles, subtract the pairs, add the triples, and so on.
The matching problem (Pierre de Montmort, 1708). n letters are put into n addressed envelopes at random. What is the probability that at least one letter is in its own envelope?
Let Ai be “letter i is in envelope i”. P(Ai) = 1/n. Any k particular letters all match with probability (n − k)!/n!, and there are C(n, k) ways to pick them, so the k-th sum is C(n, k)(n − k)!/n! = 1/k!:
The series is the Taylor series of 1 − e−1. It settles fast: by n = 7 it agrees with the limit to 4 places, so the chance is about 63% for 7 letters or 7 million.
For 6 letters it is 0.6319: 265 of the 6! = 720 orders have no match. In the figure, 39 of 60 shuffles had at least one.
sampling with replacement, order not mattering
How many ways are there to put k identical balls into n distinguishable boxes? The answer is the fourth entry of the sampling table: C(n + k − 1, k).
The code. Write each way as a row of 7 stars (the balls) and 3 bars (the walls between the 4 boxes). ★★|★★★||★★ means 2, 3, 0 and 2. Every row of 7 stars and 3 bars is exactly one way, so count the rows: choose which 3 of the 10 places hold bars.
If every box must get at least one ball, put one in each first, then place the other 3 freely: C(3 + 3, 3) = C(6, 3) = 20 ways.
A warning about probability. These 120 ways are not equally likely if the balls are thrown in at random. All 7 in box 1 can happen in one way, but 2, 2, 2, 1 can happen in 7!/(2! 2! 2! 1!) = 630 ways once the balls are told apart. The naive definition needs equally likely outcomes, so count with the balls labelled. Physicists call identical particles that really do follow this count bosons (Bose–Einstein statistics).
Stars and bars also counts whole-number solutions: x1 + ⋯ + x4 = 7 with every xi ≥ 0 has 120 solutions.