The Birthday Paradox

Tivadar Danka small portrait Tivadar Danka

Understanding math will make you a better engineer.

So, I am writing the best and most comprehensive book about it.

Let's test your probabilistic intuition!

There are 25 people in a room. What is the probability that two of them share the same birthday? If you think it is low, you'll be surprised to find out that the actual probability is more than 50%. Here is why!

The usual thinking is if there are 25 people and 365 days in a year, then chances should be roughly 24/365 ≈ 6.5%, and if we have 366 people, then it is guaranteed that two of them share birthdays. However, this is not how probability works.

First, it is much easier to talk about the probability of having no shared birthdays. This is a common trick, often making the calculations much more manageable.

P(shared birthdays)=1P(no shared birthdays)P(\text{shared birthdays}) = 1 - P(\text{no shared birthdays})

Let's simplify the problem even more! Given two people, what is the probability of sharing the same birthday? By encoding the birthday with an integer between 1 and 365 and the configurations as tuples, we can easily count their total number. This is how we represent birthdays:

configurations={(i,j):i,j{1,2,,365}}.\text{configurations} = \Big\{(i, j): i, j \in \{1, 2, \dots, 365\}\Big\}.

How many days can we pick as the 1st element of the tuple? 365365. How many days can we pick as the 2nd element to avoid the birthday collision? 364364.

In total, there are 365364365 \cdot 364 ways.

Birthday configurations for the birthday problem with two people

To count the number of total configurations, we simply disregard the potential birthday collision. Thus, there are 365365365 \cdot 365 possibilities.

Now we can calculate the probability as the ratio of the number of desired outcomes and all possible outcomes:

probability=#desired outcomes#all possible outcomes.\text{probability} = \frac{\# \text{desired outcomes}}{\# \text{all possible outcomes}}.

In this case, the result is

P(two people don’t share birthdays)=365364365365.P(\text{two people don't share birthdays}) = \frac{365 \cdot 364}{365 \cdot 365}.

Summing up, the probability of two people sharing the same birthdays is less than one percent.

P(two people share birthdays)=13653643653650.27\begin{align*} P(\text{two people share birthdays}) &= 1 - \frac{365 \cdot 364}{365 \cdot 365} \\ &\approx 0.27 % \end{align*}

What about the general case? Following the same logic, we can solve the general problem, obtaining

P(there are shared birthdays among n people)=1365!(365n)!365n.P(\text{there are shared birthdays among } n \text{ people}) = 1 - \frac{365!}{(365 - n)! \cdot 365^n}.

At n=23n=23 people, the probability reaches 50%. At n=41n=41, the probability is 90%. Quite surprising, isn't it? If you are curious, this is what the probabilities look like.

Probability of at least two people sharing the same birthdays

What can we learn from the birthday problem? That our intuition about probability often fails hard. When asked, most estimate the chances of having a shared birthday among 25 people very low, even though the actual probability is more than 50%.

Having a deep understanding of math will make you a better engineer.

I want to help you with this, so I am writing a comprehensive book that takes you from high school math to the advanced stuff.
Join me on this journey and let's do this together!