Birthday Probability
If there are 23 people in a room, what is the probability that two persons share the same birthday?
Can you believe that the probability is more than 50%? Yes… I am not kidding, 50.7% to be exactly. How come??? There are 365 days in a year and there are only 23 people in a room.
I was very surprise too…. Honestly, I don’t have interest in probability and statistics, but recently I had to learn them to prepare my interview with Google. I have heard that they may ask this kind of questions.
Although I am not an expert in probability, I will try to explain how we get this number.
First, let’s start with a simple problem. We have 3 people in a room. What is the probability that two persons share the same birthday? Let’s take a date for the first person. The second person has probability of 1/365 to share the same birthday (we ignore leap year for simplicity). The third person also has the same probability, 1/365. We end up with 2/365.
Do we miss something? Indeed, yes. There is a probability that the second person shares the same birthday as the third person. Things are getting more complicated for 23 people.
How do we solve this problem then? We all know this formula from our class in high school:
P(two persons share the same birthday) = 1 - P(no two persons share the same birthday).
It’s easier to find the probability of no two person share the same birthday, isn’t it?
Back to our problem, let’s take a date for the first person from 23 people. The probability that the second person doesn’t share the same birthday is 364/365. The probability of the third person is 363/365. The probability of the fourth person is 362/365, and so on. So we end up in the following equation:
P(two persons share the same birthday) = 1 - (364 / 365) * (363 / 365) * … * (343 / 365)
P(two persons share the same birthday) = 50.7%
Update (28-Oct-06): Just additional note, Google didn’t ask me this question during interview. I just heard they may ask this kind of questions during the interview. Read this posting for an example.
you are at a party with a friend and 10 people are present including you and the friend. your friend makes you a wager that for every person you find that has the same birthday as you, you get $1; for every person he finds that does not have the same birthday as you, he gets $2. would you accept the wager?
For my case, they asked computing and programming questions. No brain teaser questions.
October 28th, 2006 at 10:37 pm
Uh.. how can P = 1-P? Let’s just substitute that P with a number, say 0.3, this means that 0.3 != 1-0.3. So the basis of your conclusion is wrong.
Maybe what you mean is P (probability of people shared the same birthday) + Q (the probability of people doesn’t share the same birthday) = 1. Therefore P = 1 - Q. And since Q = 1 - P, then P = 1 - (1-P), which will throw us back onto an infinite loop.
Care to try a different solutions?
Mind you, I’m no expert on statistic, nor I’m smart enough to be recruited into google and I might be wrong in this.
October 28th, 2006 at 10:39 pm
Oh shrugs… just read the entire post and I realized that the logic is right, just the notation of the formula is wrong.
My bad :D, mind to change the P = 1 - P to something else (to differentiate that the P in the right side is different than the P in the left side).
Creative solutions by the way
October 28th, 2006 at 10:42 pm
@Oskar: Note there is “no” at the second P…
I will put a “bold” in the “no” so that it is clearer.
October 28th, 2006 at 10:45 pm
@Oskar: Yes, may be I should use different notation on the right side.
Anyway, Google didn’t ask this kind of question during my interview. They asked technical questions about computing and programming. I don’t think I will have a chance to go to the next interview…
October 29th, 2006 at 7:45 pm
I’ve heard this before. This is one of famous paradoxes in math. anyway, there’s an article in wikipedia :
http://en.wikipedia.org/wiki/Birthday_problem
October 29th, 2006 at 9:14 pm
@ech: Thanks for the link. Poor me that I didn’t check Wikipedia….
October 30th, 2006 at 1:33 am
Halo Antony, kalau by Intuition di bagian “understanding the paradox” di wikipedia sudah cukup memberikan gambaran, sempat disinggung di sub-bab 8.4.4 Buku Computer Networks (0-13-066102-3). Jebakannya karena ada pigeonhole yg harus disertakan seperti yg diutarakan oleh Wikipedia “..It is easier to first calculate the probability p(n) that all n birthdays are different. If n > 365, by the pigeonhole principle this probability is 0. On the other hand, if n ? 365, it is given by..”. Bila Pigeonhole tidak disertakan orang tergoda untuk menghitung seperti menghitung probabilitas dua buah dadu atau dua buah uang logam.
October 30th, 2006 at 8:47 am
@Edo: Emang betul, jebakannya itu yang bikin orang menghitung P yang pertama. Saya juga waktu lihat problem itu menghitung dari P yang pertama. Terus muter2 gak karuan tanpa juntrungan akhirnya. Maklum, bukan expert probability sih…
January 25th, 2008 at 1:23 pm
Because I am definitely not into doing all that math (it makes my eyes cross), tell me what are the odds of this: of the 24 people in my office, five sets have the same birthday. Honest to God, this is true!