The Birthday Paradox Birthday Paradox Objectives: STUDENTS WILL: 1. Memorize the definition for probability and for compound events. 2. Discuss the probability of isolated and compound events. 3. Apply knowledge of probability to find probability of remaining event(s). 4. Differentiate between isolated and compound events in the Birthday Paradox. 5. Propose and defend methods for solving the Birthday Paradox using knowledge of probability. 6. Develop pseudo code for solving the Birthday Paradox in Matlab. Birthday Paradox How likely is it that two people in this room have the same birthday? How many people are needed to ensure that the probability of having at least two people with the same birthday is 50%? Birthday Paradox Probability – the likelihood that something will occur or be true P(E ) Number of Elements in ' E' Size of the Sample Space The sum of all probabilities for all events in the sample space must sum to 1. P ( E 1 ) P ( E 2 ) ... P ( E N ) 1 . 0 Birthday Paradox Compound Events – 2 or more independent events occurring in sequence. P ( E 1 and E 2 ) P ( E 1 ) * P ( E 2 ) Birthday Paradox How likely is it that two people in this room have the same birthday? It’s actually easier to get at the inverse. What is the probability that two people will NOT have the same birthday? P(E ) # Days/Yr - Birthday # Days/Yr P(E ) 364 365 0 . 997 Birthday Paradox Now that we know the probability that two people chosen at random WON’T have the same birthday, we can figure out the probability that they WILL have the same birthday… Sum of All P(E) 1 . 0 P ( match ) P ( no match ) 1 . 0 P ( match ) 1 . 0 P ( no match ) 0 . 003 Birthday Paradox How many people are needed to ensure that the probability of having at least two people with the same birthday is 50%? Let’s see how this plays out in Excel… # of Students # of Non-matching P(no match) P(no match) for P(match) for Checked Birthdays for Nth student first N students first N students 1 365 1.000 1.000 0.000 2 364 0.997 0.997 0.003 3 363 0.995 0.992 0.008 4 362 0.992 0.984 0.016 5 361 0.989 0.973 0.027 6 360 0.986 0.960 0.040 7 359 0.984 0.944 0.056 8 358 0.981 0.926 0.074 9 357 0.978 0.905 0.095 10 356 0.975 0.883 0.117 11 355 0.973 0.859 0.141 12 354 0.970 0.833 0.167 13 353 0.967 0.806 0.194 14 352 0.964 0.777 0.223 15 351 0.962 0.747 0.253 16 350 0.959 0.716 0.284 17 349 0.956 0.685 0.315 18 348 0.953 0.653 0.347 19 347 0.951 0.621 0.379 20 346 0.948 0.589 0.411 21 345 0.945 0.556 0.444 22 344 0.942 0.524 0.476 23 343 0.940 0.493 0.507 24 342 0.937 0.462 0.538 Birthday Paradox Now let’s try programming the Birthday Paradox in Matlab so that we can practice our programming skills… Useful Matlab Functions: sort, find, isempty, ceil, rand, sum, for, while Birthday Paradox function [ P ]=BirthdayParadox( N, M ) %N is the number of iterations %M is the number of people being tested; by default, M = 23. %1. Create random birthdates for M students. %2. Sort the birthdates in ascending order. %3. Determine if there are matching birthdays. %4. If there are matching birthdays increment the MATCH counter. %5. Repeat steps 1-4 for N iterations. %6. Sum up all of the iterations with matching birthdays and divide by the total number of birthdays. end