[Home] [Puzzles & Projects] [Delphi Techniques] [Math Topics] [Library] [Utilities]
Shared Birthdays - with leap years considered.
This is an extension of the Shared Birthdays discussion started here.
On this page we'll investigate the probability that at least two people in a room with N people share a birthday and allowing for the possibility that some may have a birthday on February 29th. The are two mutually exclusive cases to consider:
1.) Either everyone in the room has a unique birthday and no one has a Feb 29th birthday. We will denote the probability of this event as P1(N). Or ....
2.) Everyone in the room has a unique birthday and exactly one person has a Feb 29th birthday. We'll call the probability of this P2(N).
These 2 cases do not overlap and cover all possibilities where everyone has a different birthday, so we may sum the two probabilities and subtract from 1 to get the probability that two or more share a birthday.
Case 1 - Unique birthdays and no Feb29th birthday
P1(N) is similar to the calculation used when we ignored leap year birthdays, except we allow for the fact that years average 365.25 days. (I still ignore the 100 and 400 year leap year exceptions.) The probability that first person has a unique birthday not Feb29th is P1(1)=365/365.25. The probability that the second person does not have the 1st person's birthday and does not have a Feb 29th birthday is (365/365.25)*(364/365.25). For the 3rd person the probability is (365/365.25)*(364/365.25)*(363/365.25) and in general for the Nth person the probability P1(N) = P1(N -1)*(366-N)/365.25.
Case 2 - Unique birthdays and a single Feb 29th birthday
This case is more complicated. The probability of person N being unique and meeting the single Feb 29th condition depends on whether the Feb29th birthday already exists. We'll call the probability in the case where the Feb 29th slot is taken among the previous occupants P2a, and if Feb29th is not taken we'll call it P2b. Again these are exclusive cases so we may add the probabilities to get the total probability of the event. P2(N)=P2a(N)+P2b(N).
Since we must have a single Feb29 birthday, for N=1 the probability is 1 chance in 1461, the number of days in four years when a leap year is included. We can write this as P2a(1)= .25/365.25. P2b(1)=0 of course.
Now the second person enters the room. If person #1 was not a Feb 29th, then by definition of this case, person #2 must be Feb 29th and P2a(2)=(365/365.25)*(0.25/365.25). If person #1 was a Feb29th then person number 2 must not be and P2b(2)=(0.25/365.25)*(365/365.25). Person #2 can celebrate any of the 365 days since person #1 had Feb 29th.
In the general case for P2a, Feb 29th is already taken when person N enters the room and the probability of that is P2(N-1) by definition. So P2a(N)=P2(N-1)*(367-N)/365.25).
For P2b, birthdays unique and Feb 29th not taken when N enters, just happens to be P1(N-1) so when N enters the room he must be a Feb 29th and the probabilities are P2b(N)=P1(N-1)*(0.25/365.25).
And just to complete the story.
The probability of one or more shared birthdays for room with N randomly selected people is 1 - (P1(N) + P2(N)).
The program displaying probabilities for N between 1 and 100 with and with the leap year calculation is available for downloading at Shared Birthdays or below.
Running/Exploring the Program
Copyright © 2000-2013, Gary Darby
All rights reserved.