Birthday Paradox
See why 23 people is enough to share a birthday, the theory and a live simulation, side by side.
The birthday paradox is the standard example of a true thing that feels wrong: in a room of just 23 people, it's more likely than not that two of them share a birthday. Most people hear the answer, nod, and still don't believe it, because the explanation is a formula, and a formula doesn't move. I wanted something you could push on instead of read.
So this puts the math and the experiment in the same view. On one side is the exact probability curve; on the other is a Monte Carlo simulator that actually deals out random birthdays, trial after trial, and tallies how often a collision shows up. Watch the empirical number climb toward the theoretical one and the result stops being a claim you take on faith and starts being something you just saw happen.
How it works
- Plots the exact curve: the theoretical probability P(N) for group sizes from 1 to 100, with the 50% crossover at N = 23 annotated right on the line.
- Runs a live simulation: a Monte Carlo engine deals random birthdays for up to 100,000 trials and reports a running empirical estimate next to the theoretical value, so you can see how far off it is at any moment.
- Stays smooth under load: the trials are chunked across requestAnimationFrame frames instead of run in one blocking loop, so the progress bar animates and the page stays responsive even at 100k.
- Lets you turn the knobs: adjust the group size (1–100) and the trial count (100, 1k, 10k, 100k) and re-run to feel how each one changes the answer and the noise.
- Shows a single sample: a calendar of all 365 days renders one random draw of the current group, with any collision days lit up in red so you can see a match concretely.
Stack
Vite · React 18 · TypeScript (strict) · Tailwind · Recharts. Dark and light themes with system auto-detect and a manual override; ships as a static bundle to GitHub Pages, so it runs entirely in the browser with no backend.