keys are hashed independently and uniformly into slots. How do you find the probability that at least two keys share a slot, and how large must be for this probability to pass when (the birthday problem)?
Probability and statistics, Probability axioms and counting
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you use the complement rule and the product of conditional probabilities, and can turn it into the approximation .
Key idea
, so collisions become likely once is of order , not .
Steps
- Use the complement: . Counting the 'no collision' case is easier.
- Place the keys one at a time. The first key can go anywhere. The th key must avoid the slots already used, which has probability .
- Multiply, since the placements are independent: .
- Approximate with for small : .
- Set : , so . For this gives about , so .
- Check numerically: the exact product for gives (the approximation gives ). As a second example, 10 keys in 100 slots collide with probability , which is already large.
Common mistakes
- Computing and thinking 23 people in 365 days is a chance. That ignores that there are pairs, which grows like .
- Multiplying terms that start at instead of , which gives an off-by-one error in .
- Assuming slots are equally likely. For non-uniform hashing, collisions are more likely than the formula says.
How long your answer should be
Half a page; 3–4 minutes.
Read this
Previous in Probability and statistics: For a bivariate Gaussian with correlation , show that . What is the value for , and what happens as and ?
Next in Probability and statistics: Three independent jobs have exponential run times with rates , and per hour. What is the distribution of the time until the first job finishes, and what is the probability that job 1 is the first to finish?