The birthday bet
Nov
11

Imagine you go to a party with me. Let’s say there are 50 people in there.

I say: “I bet everything you have there’s two people in this party whose birthdays are the same.”
You think: “50 people… out of 365 days in a year? It’s definitely hard to have two guys with the same birthday. Let’s bet!”

You, my friend, should start looking for a bridge to live under, because your house, your car and your wife are now mine.

Photo by The Random Snapper.

### The math

OK, I know this sounds counterintuitive, but it’s all backed up by real math. So let’s jump in to that.

Note: We will assume all years have 365 days, just to simplify things a bit.

First, let’s define the problem. We are interested in finding out my chances of winning the bet. In other words, calculating the probability of two of the people in the party having the same birthday. To do that, we will first calculate exactly the opposite: the probability of everybody in the party having a different birthday.

So we can reformulate the problem as follows: “Let n be the number of people in a party. Calculate the probability of each of the n people having a different birthday.”

And how do we calculate this? Piece of pi:
Take the first person in the party, and write down his birthday. Then take the second. Since we can’t allow two people with the same birthday, this person’s birthday must be one of the 364 days that are not the first person’s birthday. The probability of this happening is 364/365 (there are 364 ‘good’ days out of 365 possible options).

So the probability of everybody having a different birthday on a party with two people is:

$\frac{364}{365} = 0.997260273972603$

That means that your chances of winning in a party of two people are above 99%. Not good for me.

Now take the third person. His birthday must not be one of the two previous people’s birthdays. So he’s only got 363 out of the 365 days.

So the probability of everybody having a different birthday on a party with three people is:

$\frac{364}{365} \times \frac{363}{365} = 0.991795834115219$

Now take the fourth person. His birthday must not be one of the three previous people’s birthdays. So he’s only got 362 out of the 365 days.

So the probability of everybody having a different birthday on a party with four people is:

$\frac{364}{365} \times \frac{363}{365} \times \frac{362}{365} = 0.98364408753345$

And so on. In general, the probability of everybody having a different birthday on a party with n people is:

$\frac{364}{365} \times \frac{363}{365} \times \frac{362}{365} \times \dots \times \frac{(365 - n + 2)}{365} \times \frac{(365 - n + 1)}{365}$

or more succinctly:

$\prod_{i=1}^{n-1} \frac{365 - i}{365}$

Now, let’s find out how’s the deal when there are 50 people. Let’s use this little Ruby program to evaluate the formula for us:

 1 2 3 4 5 6 7 8  def formula(n) p = 1.0 1.upto(n - 1){ |i| p *= (365.0 - i) / 365 } "Party of #{n} people: The probability of you winning the bet is #{p}. The probability of me winning the bet is #{1.0 - p}." end

Let’s try it out:

 1 2 3 4  >> formula(1) "Party of 1 people: The probability of you winning the bet is 1.0. The probability of me winning the bet is 0.0."

This makes sense. How can two people have the same birthday if there’s only one person in the party?

 1 2 3 4  >> formula(2) "Party of 2 people: The probability of you winning the bet is 0.9972602739726028. The probability of me winning the bet is 0.002739726027397249."

Right, what we had said above. Not too convenient for me.

With three people:

 1 2 3 4  >> formula(3) "Party of 3 people: The probability of you winning the bet is 0.9917958341152187. The probability of me winning the bet is 0.008204165884781345."

Not too good, either.

Now let’s jump and see what happens in a 50 people party:

 1 2 3 4  >> formula(50) "Party of 50 people: The probability of you winning the bet is 0.029626420422011596. The probability of me winning the bet is 0.9703735795779884."

Whoa! Did you see that? Now my chances increased to above 97%.

Now, go find some unwary rich people and bet! You’ll win in about 97 out of 100 parties.