In a group of 23 people, there is a 50% chance that 2 people have the same birthday. By the time you get past 50ish people, that number effectively becomes 100%.
The first time my little reptile brain heard that “paradox” it gave me a headache. There are 365 days in a year, so the odds of two people having the same birthday, should be like, less than 1%, right? So even multiplying that through a bigger sample – surely couldn’t get to 50%? Right? RIGHT?
I was about to get crazy, and try to pull Facebook API’s, census records, or make more friends in order to create a significant number of groups, and see if I can get to 50%. Because I don’t learn math by numbers, I learn math by breaking stuff. Then I remembered something. I have Python. And, like what we explored in fictional friends, I can just make up people and have the same effect.
Methodology
- Using Python, create a function to create a script to create people, with an ID, Name, and a random birthday.
- Using Python, create a function to create a group of people, which calls the “Create Person” function, a number of times (ideally 23 to test)
- Using Python, create a function, creating groups a significant number of times, to create “matches”, returning the match back, with the independent variable being group-size and the dependent variable being how many groups had a match (represented as a probability).
- Run, graph, analyze
Code Review
Checkout the repo here, for how it’s done. Why did I name people? Because people, even fictional people, deserve a name.
Results
I ran 1,000 simulations of each group size ranging from 2, to 100 to examine each probability. At a group size of 23, 478 groups had matches, meaning the probability was 47.8%. At 25, it jumped to 53%.

How is this possible? Why is this so confusing?
It’s because we’re looking at pairs of people, not individuals, and not compared to a certain date. For example, we’re not talking about 23 individuals, we’re talking about 253 possible pairs.
Of if you want to calculate possible pairs in this case, it would be…
After you adjust the math for pairs, you find the lambda…
So now we calculate the probability of no matches…
So to calculate the probability of a match, just subtract 1 minus the probability of no matches…
Why did I add 2.718 in for e? Because it’s a rough constant, like
. Don’t worry, I had to look it up too.
Sanity check! Let’s do the same thing for 50 groups.
So for example, a group size of 50 would be…
In the simulation, when I did it “for real” 969 groups had a match, so roughly 96.9% probability. Pretty close!
Math is neat.
Stay Curious!

Leave a Reply