Path: blob/main/notebooks/published/birthday_paradox_simulation/birthday_paradox_simulation.ipynb
51 views
Birthday Paradox Simulation
Introduction
The Birthday Paradox (also known as the Birthday Problem) is a counterintuitive result in probability theory that demonstrates how quickly the probability of a shared birthday grows with group size.
Theoretical Foundation
Problem Statement
Given a group of randomly chosen people, what is the probability that at least two people share the same birthday?
Assumptions
There are 365 days in a year (ignoring leap years)
Birthdays are uniformly distributed across all days
Each person's birthday is independent of others
Analytical Solution
It is easier to first calculate the probability that no two people share a birthday, then subtract from 1.
For people, the probability that all birthdays are distinct is:
This can be written as:
Therefore, the probability of at least one match is:
The Surprising Result
The paradox lies in the fact that:
With just people,
With people,
With people,
This is counterintuitive because we naturally compare to 365, but the key insight is that we're counting pairwise comparisons, which grow as .
Computational Implementation
We will:
Calculate the exact theoretical probability
Run Monte Carlo simulations to estimate the probability empirically
Compare theoretical and simulated results
Analysis and Discussion
Why is this Paradoxical?
The Birthday Paradox seems surprising because our intuition compares the number of people () directly to the number of possible birthdays (365). We instinctively think: "With only 23 people and 365 days, how can there be a 50% chance of overlap?"
However, the key insight is that we're not asking whether a specific person shares a birthday with someone else. We're asking whether any pair shares a birthday. The number of pairs grows quadratically:
For : pairs to compare!
Approximation for Large
For large groups, we can approximate using the Taylor expansion :
Applications
The Birthday Paradox has important applications in:
Cryptography: Birthday attacks on hash functions exploit this principle. A hash function with -bit output can be broken in approximately operations, not .
Database Systems: Estimating collision probabilities in hash tables and unique ID generation.
Quality Control: Detecting duplicates in datasets.
Conclusion
Our simulation confirms the theoretical prediction with excellent agreement. The Birthday Paradox beautifully illustrates how combinatorial growth can lead to counterintuitive probability results, with practical implications across computer science and mathematics.