# Probability question (Birthday problem)

I was wondering if someone could critique my argument here. The problem is to find the probability where exactly 2 people in a room full of 23 people share the same birthday.

My argument is that there are 23 choose 2 ways times $\displaystyle \frac{1}{365^{2}}$ for 2 people to share the same birthday. But, we also have to consider the case involving 21 people who don't share the same birthday. This is just 365 permute 21 times $\displaystyle \frac{1}{365^{21}}$. To summarize:

$$\binom{23}{2} \frac{1}{365^2} \frac{1}{365^{21}} P\binom{365}{21}$$

• The idea is good. We need to choose the $2$ people. Then we need to choose a birthday for them. Then we need to choose different birthdays for the others. The numerator will be a little different from yours, we need to choose different birthdays for $22$ "people," our birthday pair and the other people. The denominator is right. – André Nicolas May 3 '12 at 4:17
• Why are you multiplying by $1/365^2$? Are you trying to count (as your use of "there are .... ways..." suggests) or probability? And are you taking into account that among the other 21 people two may share the same birthday, though not have it the same day as the two you selected to begin with? I don't understand your throught process... – Arturo Magidin May 3 '12 at 4:17
• My thinking is that there are 23 people and each have a probability of $\frac{1}{365}$ of sharing the same birthday if I want 2, then I would have to pick 2 people from that group of 23. That is the reason why I multiplied $\frac{1}{365}$ by $\binom{23}{2}$. My calculation for the other 21 people takes into account that every person has a different birthday from the other. Andre seems to think I should consider 22 people and not 21 for the numerator. I've got to think... – Low Scores May 3 '12 at 4:27
• @LowScores: You seem to be trying to both count and compute probabilities at the same time. Can't really do that. It's also false that "there are 23 people and each has a probability of 1/365 of sharing the same birthday". Sharing the same birthday with whom? Again: are you trying to count the number of ways in which exactly two people can share a birthday (so that then you can compute probability as "number of good cases"/"number of total cases", or are you trying to compute probability along the way? It might be simpler if you first count, and then you compute probability. – Arturo Magidin May 3 '12 at 4:33
• @LowScores If you are counting the number of ways to get just one match then as Andre Nicolas said, you need to count the number of ways to get one match, but then also make sure there are no other matches by having the rest not be matching. – yiyi May 3 '12 at 4:52

The basic idea was right, and a small modification is enough.

Line up the people in some arbitrary order. There are, under the usual simplifying assumption that the year has $365$ days, $365^{23}$ possible birthday sequences. Under the usual assumptions of independence, and that all birthdays are equally likely, all these sequences are equally likely. The assumption "equally likely" is not correct, though it is more correct for people than for eagles.

Now we count how many ways we can have precisely $2$ people have the same birthday, with everybody else having a different birthday, meaning different from each other and also different from the birthday of our birthday couple.

The couple can be chosen in $\binom{23}{2}$ ways. For each of these ways, the couple's birthday can be chosen in $365$ ways. And the birthdays of the others can be chosen in what is sometimes called $P(364,21)$ ways. (I have always avoided giving it a name.) So the number of birthday assignments that satisfy our condition is $$\binom{23}{2}(365)P(364,21), \quad\text{that is,}\quad \binom{23}{2}(365)(364)(363)\cdots (344).$$ For the probability, divide by $(365)^{23}$.

Remark: Or else argue this way, which may be closer in spirit to your thinking. Pick two people, $i$ and $j$. What is the probability these two have the same birthday, and all other birthdays are different from this one, and different from each other? Whatever $i$'s birthday is, the probability that $j$'s matches it is $\frac{1}{365}$. By the usual birthday argument, the probability that the birthdays of the other people are different, and different from the birthdays couple's, is $$\frac{364}{365}\frac{363}{365}\frac{363}{365}\cdots\frac{344}{365}.$$ Multiply the above expression by $\frac{1}{365}$. Finally, sum the result over the $\binom{23}{2}$ ways to choose $i$ and $j$, that is, multiply by $\binom{23}{2}$.

A brief simulation using R software permits verification of some proposed methods and gives answers to some related questions. Below X is the number of matches (defined as number of people minus number of redundant birthdays). A million iterations provide about three place accuracy; smaller values of m run faster, but have somewhat larger simulation error.

m = 10^6; x = numeric(m); n = 23

for (i in 1:m) {

birthdays = sample(1:365, n, rep=T)

x[i] = n - length(unique(birthdays)) }

mean(x == 0) # Exact P{X = 0} = 0.4927028

 0.493275

mean(x == 1) # Exact P{X = 1} = 0.3634222

 0.362928

mean(x) # Approx E(X)

 0.67928

sd(x) # Approx SD(X)

 0.7921738

The exact probability of no matches is from 'prod(365:343)/365^23' or 'prod(1 - (0:22)/365)'. The exact probability of one match is from 'choose(23,2)*prod(365:344)/365^23'. The approximation of the PDF of X from the simulation can be obtained from 'table(x)/m', and it is closer to exact than the Poisson approximation with mean (23*22)/(2*365). Simulation results above use 'set.seed(1234)'. A similar simulation is shown in Suess & Trumbo: "Intro. to Probability Simulation...", Springer (2010), pages 4-7. (The Amazon ad permits viewing a few pages, including some explanation of this R code.)

A slightly modified simulation can approximate the more realistic case in which not all birthdays are equally likely (and can include Feb. 29). The modest day-to-day variation in birthday frequencies in the US seems to affect the second decimal places of P{X = 0} and E(X) by about one digit.

Bruce Trumbo

This question has been asked in more ways than there are Buddhas. Try looking here https://math.stackexchange.com/search?q=birthday+problem