# Birthday Problem for 3 people

I know that, in a room of 23 people, there is a 50-50 chance that two people have the same birthday. However, what I want to know is: How many people do you need to have a 50-50 chance that 3 people share the same birthday?

Note: Assume for this question, that birthdays are equally distributed

• math.stackexchange.com/questions/25876/… – user940 Sep 6 '13 at 4:38
• BirthDay Problem ---> en.wikipedia.org/wiki/Birthday_problem – Felix Marin Sep 6 '13 at 4:47
• The linked question asks for the probability for 30 people. What I want is the amount of people needed for the probability to be above 50%. – Thomas Sep 6 '13 at 5:04
• Notice that the number 23 uses the assumption that birthdays are equally distributed, i.e., that every birthday is equally-likely, with probability 1/365 (or 1/366). There is data that puts this into doubt, at least in the U.S. – DBFdalwayse Sep 6 '13 at 5:10
• My question is assuming that the distribution is uniform. – Thomas Sep 6 '13 at 5:31

The question linked in the comments, while not your exact question, is very relevant. In particular, reading the answers posted there will tell you that an exact computation for triples is gross. However, Byron Schmuland's answer gives us a useful estimate: $$P(\text{at least one triple with } N \text{ people}) \approx 1 - e^{-{N \choose 3}/365^2}$$ From this we can simply solve for what $N$ makes this value $\frac12$. We need \begin{align*} 1 - e^{-{N \choose 3}/365^2} &= \frac12 \\ e^{-{N \choose 3}/365^2} &= \frac12 \\ e^{{N \choose 3}/365^2} &= 2 \\ {N \choose 3} &= 365^2 \ln 2 \\ N(N-1)(N-2) &= 6 \cdot 365^2 \ln 2 \\ N^3 - 3N^2 + 2N - 6 \cdot 365^2 \ln 2 &= 0 \end{align*}

A computer calculation reveals that the only real root of this cubic polynomial is $N \approx 83.13$. Hence we would expect to need $83$ or $84$ people in the room before having a 50-50 chance of getting three people with the same birthday.

UPDATE: This is only an approximation, and it turns out it's off by more than I expected. To get an exact answer, I used the exact formula given here, and found that $N = 87$ is actually closest, with a probability of $.49945$ that three people have the same birthday.

• Shoudn't the probability be over $365^3$ instead of $365^2?$ – vantonio1992 Sep 6 '13 at 6:00
• @vantonio1992 check out Byron's answer in the linked question. $1/365^2$ is the chance of a given three people having the same birthday. – 6005 Sep 6 '13 at 6:02
• This comment in particular: math.stackexchange.com/questions/25876/… – 6005 Sep 6 '13 at 6:03
• Interesting that it is about double of the amount needed to ensure 50-50 for two people having the same birthday. – Thomas Sep 6 '13 at 6:07
• Interesting, I wonder how many people you need for four people to share a birthday with 50% probability. If we made a graph of the function f(n) of the number of people needed to be 50% sure that n people have the same birthday, what would it look like? – Thomas Sep 7 '13 at 4:55

Empirically the answer seems to be $87$ or $88$.

More precisely, the probability of at least three people sharing a birthday is very close to $0.50$ if there are $87$ people in total (making the standard assumption of an i.i.d. uniform distribution over $365$ days).

Using the following R code to test a million cases for $87$ people in a room

days   <- 365
people <- 87
cases  <- 1000000
set.seed(1)
maxhits <- function(x){ max(table(x)) }
eg <- matrix(sample(days, people*cases, replace = TRUE), nrow=cases)
table(apply(eg, 1, maxhits) )


the sample distribution for the most people sharing a single birthday was

 1      2      3      4      5      6      7
13 500212 461918  36116   1688     50      3

• Indeed 87 or 88 is what I get also. Cheers – 6005 Sep 6 '13 at 9:28
• Deeper calculation gives rounded probabilities of at least three people sharing a birthday of $84-0.464549768$ $85-0.476188293$, $86-0.487826289$, $87-0.499454851$, $88-0.511065111$, $89-0.522648262$ so the median of the first time this happens is $88$ though $87$ is close, while the mode is $85$ and the mean is about $88.73891765$ – Henry Aug 2 '17 at 23:04
• What do you mean by the median, mean, and mode? There is just one first time this happens, at $88$. I am having trouble understanding – 6005 Aug 3 '17 at 19:05
• @6005: It can in fact first happen as a random variable at any time from $3$ through to $2\times 365+1=731$, with median, mode and mean as stated, and standard deviation of about $32.832597$ – Henry Aug 3 '17 at 20:31
• Thanks, I see what you meant now. – 6005 Aug 3 '17 at 20:35

There are 2 approaches to this kind of question (3 people with the same birthday...) You either 1) just want the answer. 2) want the satisfaction and understanding that comes from figuring it out from basic probability theory. (This can be a long hard road with no success guaranteed no matter how creative you are or how hard you work.)

If you just want the answer, the best way to get it is to write a little program that gets the answer by experiment. Using a random number generator to provide the data, and repeating the experiment a large number of times (for instance, 1,000,000 times) and seeing the result. You can easily get the answer to the birthday problem for any number of same birthdays (Sames), and also get answers to related questions- like, On the average how many pairs (OneLesses) of people had the same birthday at the time a new person had the same as one of the pairs making 3 with the same bday.
For this problem, Sames=3, OneLesses=number of pairs

the C code is below. It was created and run in the Pelles C compiler for windows, a free program.

In the case of the 3 person birthday problem, the results for a million runs the output of the program is-

" Avg # of tosses to get 3 Sames from 365 birthdays = 88.6971 Avg # of OneLesses, i.e. pairs, before 3 Sames from 365 birthdays = 10.1309"

So the average number of people in a room before there being 3 with the same birthday is 88.7 and at the time that happened, there were, on the average, 10 pairs of people with the same birthday already in the room.

C code->

  Over=0;


while (!Over) {

             printf(" enter NumTrials,   ");
scanf("%d",&NumTrials);

printf(" enter number of outcomes,   ");
scanf("%d",&Outcomes);

printf(" enter number of Sames,   ");
scanf("%d",&Sames);

TotalTosses=0;
TotalOneLesses=0;
MaxCount=0;

for (i=1; i <= NumTrials; i++)
{
//  FOR NumTrials loop
// initialize
for(j=0; j<=Outcomes; j++)  Results[j]=0;
Count=0;
OneLess=0;

Done=0;
while(!Done)
{
toss= rand () % (Cards) ;
Count++;
Results[toss]++;

if ( Results[toss]== (Sames-1) )  OneLess++;

if ( Results[toss]==Sames) Done=1;

}  // End of While!Done

Tosses[Count]++;

TotalTosses+= Count;
TotalOneLesses+= OneLess;

}// for (NumTrials)

AvgTosses= (double)TotalTosses /NumTrials ;
printf( "Avg # of tosses to get %d Sames from %d Outcomes = %.4f \n ", Sames, Outcomes, AvgTosses);

AvgOneLesses= (double)TotalOneLesses /NumTrials ;
printf( "Avg # of OneLesses before  %d Sames from %d Outcomes = %.4f \n ", Sames, Outcomes, AvgOneLesses);


} // END While (!Over)

                   //quit program