Suppose that we throw m balls into n bins uniformly at random, where n is a fixed number. What is the probability that some pair of balls are placed in the same bin?
Define Xi,j be the indicator variable that the i-th ball and the j-th ball go to the same bin. Its expectation is given by
E[Xi,j]=1⋅Pr[Xi,j=1]+0⋅Pr[Xi,j=0]=n1.
By linearity of expectation, we have
E[1≤i<j≤m∑Xi,j]=1≤i<j≤m∑E[Xi,j]=2nm(m−1).
When m≈2n, in expectation, there is a pair of ball going to the same bin.
However, this estimate is loose.
Define p(m,n) the exact probability that no ball goes to the same bin.
Then
p(m,n)=i=0∏mnn−i=i=0∏m(1−ni).
By inequality 1−ni≤e−ni, we have a upper bound for the above probability:
p(m,n)≤e−2nm(m−1).
Therefore, the probability that there is at least one collision is lower bounded by
1−e−2nm(m−1).
If m=n, we get e−2nm(m−1)≈e−21≈0.6. If m=2n, we get e−2nm(m−1)≈e−2≈0.14.
In the case n=365, we say that if there are n≈19 people, 40% of times some pair of them share the same birthday. If there are 36 people, the probability is over 80%.
Remark: let's play some math to bound p(m,n) asymptotically.
First, it can be proven that