The Birthday Paradox

I read something the other day that piqued my curiosity:

In a random gathering of 23 people, there is a 50% chance that two people will have the same birthday.

No way, I've been to many gatherings and I don't remember anyone having the same birthday. Then again, I never really checked..
Thus, began my journey to verify this madness. I messed around with permutations and combinations for half an hour, only to leave more confused than when I started. A new approach was needed.

I decided to look at the problem from a different angle. I could calculate (more easily) the probability of no collisions, then subtract that from 1 to get the number of collisions!

Say there are 10 marbles in front of you and each person has to pick a different marble. The first person has 10 marbles to choose from. The second person only has 9 to choose from. So the probability of 2 people choosing different marbles is:

10/10 x 9/10 = 0.9 or 90%

The probability of 3 people choosing different marbles, or having no collisions, is:

10/10 x 9/10 x 8/10 = 0.72 or 72%

This same logic can be applied to having the same birthday. The probability that two people do not have the same birthday is:

365/365 x 364/365 = 0.99726 or 99.73%

Subtract that from 1 and you get the probability that two people have the samebirthday:

1 - 0.99728 = 0.00273 or 0.27%

To make this exercise simpler, I wrote a quick python script for the calculations:

23 people in a room, 50.73% chance for a same birthday. It's really true.

In hindsight, it's similar to the penny/wheat and chessboard problem in that we don't see how quickly the compounds or "combinations" can grow. When I first saw this problem, I pictured the probability that 23 other people would have the same birthday as me (pretty low actually). What I failed to consider, however, was that the statement also includes comparing other people's birthdays with each other.

Anyways, it was a fun experiment and I learned something new.

Bonus: How many people would have to be in a room to guarantee a same birthday?