Birthday Paradox Calculator
A full collision probability curve on N days (or any finite domain), a "near-miss within k days" curve, and an action-threshold advisor that turns the numbers into recommendations. Useful for hash functions, birthday lotteries, ID assignment, and uniform random sampling audits.
Calendar days, hash buckets, two-letter prefix, etc.
Action threshold
—
Why the paradox is a paradox
The probability that at least two of N people share a birthday in a domain of D days is 1 − (D·(D−1)·...·(D−N+1))/DN. Crossing 50% at N=23 (D=365) is unintuitive because people count *pairs* (which scales quadratically) but state the question in terms of *people*. We compute the curve precisely via continued-multiplication in long numbers so we don't lose precision at large N.
Beyond a single match
Our tool also reports E(unique) — the expected number of unique birthdays/IDs after N draws — which uses the classical formula D · (1 − (1 − 1/D)N). This helps in quality-control settings where you want "by what sample size are half the categories covered?".
Use cases
Hash table sizing
How many buckets do you need before the chance of any collision falls below a budgeting number? The advisory panel answers that.
Birthday lotteries
If you want to bet that two friends share a birthday, set N=2 and trust the 1/365 single-pair number, not the viral 23-figure.
ID / coupon codes
Estimate the risk of a collision in a coupon-code prefix you intend to roll out for marketing.
When not to trust this
- Real birthdays are not uniform across the year (peaks in Sep). Use national statistics if risk matters.
- Hash functions can be inverted; this only addresses preimage, not adversarial collision attacks.
- Coupon code prefixes are not random; they have structure that the calculator cannot see.
FAQ
What does "near-miss" mean here?
The probability that at least two values lie within k days (or k units) of each other — useful for birthdays clustered around holidays.
Why does D affect the result so much?
Because the formula is comparing pairs against the size of the bin. With D very large, P goes to 0; with D=N, P is essentially 1.
What "risk" should I pick?
For cryptographic IDs aim below 2-32 (≈ 2.3e-10). For product infrastructure 1e-9 or below is safe. For human-facing products where collision triggers a fallback, 1e-6 is a working rule.