Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The (so-called) Birthday Paradox: If there are 23 students in your class, what a

ID: 3657404 • Letter: T

Question

The (so-called) Birthday Paradox: If there are 23 students in your class, what are the chances that two of you have the same birthday? You can estimate this probability by generating random samples of 23 birthdays and checking for matches. Hint: you can generate random birthdays with the randint function in the random module. You can read about this problem at wikipedia.org/wiki/Birthday_paradox, import random def random_bdays(n): """Returns a list of integers between 1 and 365, with length (n).""" t = [] for i in range(n): bday = random.randint(1, 365) t.append(bday) return t

Explanation / Answer

With only a small group of people (say 23), there is a pretty good chance (50%) that at least two of those people have the same birthday. This might seem counter-intuitive given the number of days in a year, which is 366 counting the leap day. 2. It takes a very large number of people (around 850) to have a greater then 90% chance that someone has the same birthday as you. This may also seem counter-intuitive given that there are only 366 possible different birthdays, counting the leap day. Notes on these results: Theoretically, there must be 367 people in a group to insure a 100% probability that two of them have the same birthday. The reason is this: It is theoretically possible to have a group of 366 people all of whom have different birthdays because that's how many days there are in a year, counting the leap day. However, if another person was added to the group, there would be 367 people and therefore more people than there are possible birthdays and hence, it is absolutely certain that at least two of them would have the same birthday. However, because of the limitations of the programming language used, if more than 153 people are selected, the chance of two of them having the same birthday is so close to 100% that this program rounds off the answer to 100%. Even though this number is not really reached until there are 367 people in the group. Contrast this with the very unlikely possibility of selecting a random group of 850 people, all of whom have birthdays different than yours. Theoretically possible, although with a very small probability. Clearly it is possible to chose any number of people who don't have the same birthday day as you. Therefore, in any group of randomly selected people, theoretically, there will never be a 100% chance that someone has the same birthday as you. However, again because of the limitations of software used for this program, if the number of people chosen is larger than about 13680, the program rounds off the answer to 100%. Explanation of the calculations: The first calculation is done in the following way: The chance that say, five randomly chosen people do not have the same birthday is (366*365*364*363*362)/(366*366*366*366*366). The numerator represents the number of possible dates where no one has the same birthday, the denominator represents the total number of possible birthdates for five people. Call the probability that none of the five has the same birthday "p." Then the opposite probability, that at least two of them have the same birthday, is 1-p. This is what is printed above as the first result (and is called result1 in the program code.) The second calculation is done as follows: The chance that say, again five randomly chosen people do not have a given birthday, say your birthday, is (365*365*365*365*365)/(366*366*366*366*366) Here the numerator represents the number of different days in the year besides your birthday, on which each of those five people could have their birthday. The denominator represents the number of possible birthdays for five people. As before, this probability we will call p, and as before, the opposite probability, that at least one person has the same birthday as you, is therefore 1-p. (This is called result2 in the program code.