Counting and the Product Rule
Why Counting?
Many probability problems reduce to counting: determining how many outcomes lie in an event. If we can count the total number of equally likely outcomes and count how many satisfy our criterion, the probability is their ratio.
The Product Rule
Principle: If an experiment has possible outcomes, and for each of these, a second experiment has possible outcomes, then the combined experiment has possible outcomes.
More generally, for experiments:
Why does this work? Each outcome of the first experiment branches into outcomes of the second, each of those branches into outcomes of the third, and so on. The total is the product.
Examples
Example 1: Rolling Two Dice
Each die has 6 outcomes. The pair of dice has possible outcomes.
Example 2: Coin Flips
Three coin flips: each flip has 2 outcomes. Total: outcomes.
The sample space:
Example 3: Licence Plates
A licence plate has 3 letters followed by 3 digits. How many possible plates?
- Each letter position: 26 choices
- Each digit position: 10 choices
- Total:
Example 4: Hash Tables
A hash table has 100 buckets. Two strings are hashed independently. How many ways can they be stored?
Each string can go to any of 100 buckets. Total: possible storage configurations.
Ordered vs Unordered
The product rule counts ordered outcomes: the sequence matters.
Example (ordered): Drawing two balls from an urn with replacement, recording the order. If we have 5 balls, there are ordered pairs.
Example (unordered): If we only care about which two balls we get (not the order), we divide by 2! for each pair: distinct unordered outcomes (the 5 pairs of the same ball, plus 20 ordered pairs reduced by a factor of 2).
The Pigeonhole Principle
Principle: If items are placed into boxes and , at least one box contains at least items.
Corollary: If items are placed into boxes, at least one box contains at least 2 items.
Example: Hash Collisions
A hash table has 100 buckets. We hash 950 strings.
- Is it possible some bucket has no entries? Yes, the items might cluster.
- Is it guaranteed at least one bucket has at least 2 entries? Yes: , so by pigeonhole, at least one bucket has at least entries.
- Is it guaranteed at least one bucket has at least 11 entries? No: we could potentially distribute 950 items with 9 buckets having 10 items and the rest having fewer.
Counting with Restrictions
Sometimes we impose restrictions that reduce the number of valid outcomes.
Example: iPhone Passcodes
Old iPhone passcodes were 4 digits. If fingerprints appear on 3 digits (one digit used twice), how many distinct passcodes?
The passcode uses digits where one appears twice. We need to count sequences of length 4 using exactly these three digits.
Method: Choose which digit appears twice (3 choices). Then arrange 4 items where 2 are identical: arrangements.
Total: .
If fingerprints on only 2 digits: one digit used twice, another used twice. Choose which two digits (from the visible 2): must be those 2. Arrange: arrangements.
The General Counting Principle
For a sequence of choices where the th choice has options:
This assumes choices are independent: the options at each step do not depend on previous choices.
When choices depend on previous selections (sampling without replacement), each decreases.
Example: Drawing Without Replacement
Draw 3 cards from a standard 52-card deck without replacement.
- First card: 52 choices
- Second card: 51 choices
- Third card: 50 choices
- Total ordered draws:
Summary
| Concept | Formula |
|---|---|
| Product rule | |
| Pigeonhole principle | items in boxes some box has |
| Ordered sampling with replacement | sequences of length from items |
| Ordered sampling without replacement |