The Birthday Paradox
In a room full of people, what is the chance that atleast 2 of them share the same birthday? That is what we will be looking at in this post
Imagine you are sitting in a family gathering bored and all by yourself. You are too old to mingle with cousins who are half your age. Also, you are way too young to discuss politics with the elders.
If you are mathematically inclined like me, you might start to think “There are around 50 people here. What is the probability that I share my birthday with somebody in this room?”
Or “What is the probability that atleast 2 people in this room share a birthday?”
Well, that can be solved using a little bit of mathematics and probability
Defining The Problem
Let us assume there are “n” people in a room. What we require is the probability that atleast 2 people share the same birthday. For this, we will first calculate the probability that all the n people have distinct birthday‘s since it is easier to compute
Solving The Problem
Let us assume there are "n" people in a room. What are the possible cases that can occur?
All the n people have birthdays on different days - Case 1
2 people share the same birthday - Case 2
3 people share the same birthday - Case 3 and so on ........
.....
All the n people in the room have the same birthday - Case n
(From now on, I will be referring to the above as Case 1, Case 2 etc since it is easier to type. Hope it does not break the flow)
If you are familiar with basic probability, you will know that, since these are the only possible events that can occur, the sum of their probabilities is 1 i.e
p(Case 1) + p(Case 2) + p(Case 3) + ….. + p(Case n) = 1
p(atleast 2 people sharing the same birthday) = p(2 people same bday) + p(3 people same bday) + …. + p(all n people same bday)
i.e
p(atleast 2 people sharing the same birthday) = p(Case 2) + p(Case 3) + …. + p(Case n)
Substituting this in the first equation, we get
p(Case 1) + p(atleast 2 people sharing the same birthday) = 1
Hence, we conclude that
p(atleast 2 people sharing same birthday) = 1 - p(Case 1)
i.e p(atleast 2 people sharing same birthday) = 1 - p(All have distinct birthdays)
All we need to do is calculate the probability that all n people have distinct birthdays from which, we can get the required probability
Calculating The Required Probability
Let us assume there is a room where all the people have distinct birthdays.
If we place all of them in a straight line, and try to guess their birthdays, we can deduce that:
The 1st person can have his birthday on any of the 365 days. The probability of this is 365/365
The 2nd person will have his birthday on any of the days other than the 1st person's birthday i.e 364 days. Probability of this is 364/365
Similarly, 3rd person will have his birthday on any of the remaining 363days. Probability of this = 363/365.
In this way ........
The nth person will have his birthday on any of the remaining 365-(n-1) days
Multiplying the above probabilities gives us the probability of occurrence of Case 1
By subtracting the above value from 1, we can obtain our required probability
The above calculations cannot be done using pen and paper(The brave hearted ones can attempt it!). Even using a hand-held calculator will take you a considerable amount of time. I have saved you the effort by trying it out myself in Python. Those interested can try it out in any programming language of your choice (Python/R/MATLAB). All you have to do is run a simple “for” loop for the above equation and subtract the final result from 1.
I tried the above in Python and varied the number of people from 1 to 100 and got the below graph
As you can see from the above graph, the rise in probability is exponential. The probability reaches close to 99% when the number of people reaches 60. This means that if there are 60 people in a room/place, it is almost certain that there will be atleast 2 people sharing the same birthday. As the number of people increases it will reach close to 100% but not exactly. Do you know for which number the probability will become exactly 100%? Do comment your answer
The above problem is famously called the birthday paradox which states that “in a room of 23 people, there is a 50 % chance of atleast 2 people sharing the same birthday” . For 75 people, it reaches 99.9%
If you see the above graph, I have marked the corresponding probability for n=23 which is close to 0.50. As to why it is called a paradox, even I do not know the exact reason. It might be called a paradox in the sense that, we refuse to believe it when we hear it the first time. I myself, when I came across it first, was like “There are 365 days in a year. How can there be a 50 % chance of 2 people sharing the same birthday?”. But, when I did the math for myself, I was left surprised
If you are interested in knowing how the math works, refer to my next post
References
https://betterexplained.com/articles/understanding-the-birthday-paradox/