Consider this random experiment. You ask people (one at a time) of their birthdays (month and day only). The process continues until there is a repeat in the series of birthdays, in other words, until two people you’ve surveyed share the same birthday. How many people you have to ask before finding a repeat? What is the probability that you will have to ask people before finding a repeat? What is the median number of people you have to ask? In this post, we discuss this random variable and how this random variable relates to the birthday problem.
In the problem at hand, we ignore leap year and assume that each of the 365 days in the year is equally likely to be the birthday for a randomly chosen person. The birthday problem is typically the following question. How many people do we need to choose in order to have a 50% or better chance of having a common birthday among the selected individuals?
The random experiment stated at the beginning can be restated as follows. Suppose that balls are randomly thrown (one at a time) into cells (e.g. boxes). The random process continues until a ball is thrown into a cell that already has one ball (i.e. until a repeat occurs). Let
be the number of balls that are required to obtain a repeat. Some of the problems we discuss include the mean (the average number of balls that are to be thrown to get a repeat) and the probability function. We will also show how this random variable is linked to the birthday problem when
.
___________________________________________________________________________
The Birthday Problem
First, we start with the birthday problem. The key is to derive the probability that in a group of randomly selected people, there are at least two who share the same birthday. It is easier to do the complement – the probability of having different birthdays among the group of
people. We call this probability
.
where . The reasoning for the first line is that there are 365 choices to be picked in the first selection. Each subsequent random selection has to avoid the previous birthday, thus 364 choices for the second person and only
choices for the
th person.
To answer the birthday problem, just plug in values of to compute
and
until reaching the smallest
such that
and
. The calculation should be done using software (Excel for example). The smallest
is 23 since
In a random group of 23 people, there is a less than 50% chance of having distinct birthdays, and thus a more than 50% chance of having at least one identical birthday. This may be a surprising result. Without the benefit of formula (1), some people may think that it will take a larger sample to obtain a repeat.
The benefit of (1) extends beyond the birthday problem. Let’s consider the case for , i.e. randomly pick numbers from the set
with replacement until a number is chosen twice (until a repeat occurs). Similarly, let
be the probability that in
draws all chosen numbers are distinct. The probability
is obtained by replacing 365 with
.
Formula (2) will be useful in the next section.
___________________________________________________________________________
The Random Variable
We now look into the random variable discussed at the beginning, either the one for picking people at random until a repeated birthday or throwing balls into cells until one cell has two balls. To illustrate the idea, let’s look at an example.
Example 1
Roll a fair die until obtaining a repeated face value. Let be the number of rolls to obtain the repeated value. Find the probability function
where
.
Note that is the probability that it will take
rolls to get a repeated die value.
To get a repeat in 2 rolls, there are 6 choices for the first roll and the second has only one choice – the value of the first roll. To get a repeat in 3 rolls, there are 6 choices for the first roll, 5 choices for the second roll and the third roll must be out of the 2 previous two distinct values. The idea is that the first rolls are distinct and the last roll must be one of the previous values.
The reasoning process leads nicely to the general case. In the general case, let’s consider the occupancy interpretation. In throwing balls into cells, let
be defined as above, i.e. the number of balls that are required to obtain a repeat. The following gives the probability
.
where .
The reasoning is similar to Example 1. To get a repeat in throwing balls, the first
balls must be go into different cells while the last ball would go into one of the
occupied cells. For the first
balls to go into different cells, there are
ways. There are
cells for the last ball to land. Thus the product of these two quantities is in the numerator of (3).
Once the probability function (3) is obtained, the mean can be derived accordingly. For the case of
,
(calculated by programming the probability function in Excel). On average it will be required to sample about 25 people to obtain a repeated birthday.
Another interesting quantity is . This is the probability that it will take throwing more than
balls to get a repeat. Mathematically this can be obtained by first calculating
by summing the individual probabilities via (3). This is a workable approach using software. There is another way that is more informative. For the event
to happen, the first
throws must be in different cells (no repeat). The event
is identical to the event that there is no repeat in the first
throws of balls. This is how the random variable
is linked to the birthday problem since the probability
should agree with the probability
in (2).
___________________________________________________________________________
Back to The Birthday Problem
Consider the case for . What is the median of
? That would be the median number of people surveyed to obtain a pair of identical birthday. The median of
would be the least
such that
is at least 0.5. Note that
is identical to
in (1). The above calculation shows that
and
. Thus the median of
is 23. Thus when performing the random sampling of surveying birthday, about half of the times you can expect to survey 23 or fewer than 23 people.
The birthday problem is equivalently about finding the median of the random variable . A little more broadly, the birthday problem is connected to the percentiles of the variable
. In contrast, the mean of
is
. The following lists several percentiles for the random variable
.
It is clear that in a group of 366 people, it is certain that there will be at least one repeated birthday (again ignoring leap year). This is due to the pigeon hole principle. As the percentiles in the above table shows, you do not need to survey anywhere close to 366 to get a repeat. The median is 23 as discussed. The 75th percentile of is 32.
The preceding calculation shows that you do not need a large group to have a repeated birthday. About 50% of the times, you will survey 23 or fewer people, about 75% of the time, 32 or fewer people, About 99% of the time, you will survey 57 or fewer people, much fewer than 365 or 366. So with around 50 in a random group, there is a near certainty of finding a shared birthday. In a random group of 100 people, there should be an almost absolute certainty that there is a shared birthday.
For a further demonstration, we simulated the random variable 10,000 times. The range of the simulated values is 2 to 78. Thus the odds for 100 people to survey is smaller than 1 in 10,000. To get a simulated value of 100, we will have to simulate more than 10,000 values of
. The median of the 10,000 simulated results is 23. The following table summarizes the results.
Not shown in the table is that 33 of the simulated results are the value of 2. Thus it is possible to ask two people and they both have the same birthday. But the odds of that happening is 33 out of 10,000 according to this particular set of simulations (probability 0.0033). The theoretical probability of 2 is 1/365 = 0.002739726. There are 2 instances of 78 in the 10,000 simulated values. Thus the odds are 2 out of 10,000 with probability 0.0002. The theoretical probability is 0.000037 using (3).
___________________________________________________________________________