Skip to main content

Birthday Paradox: Why 23 People Give a 50% Shared Birthday

Explore how quickly shared birthdays become likely

Educational probability demonstration

Educational Tool Only: This simulator uses purely random numbers to demonstrate the birthday paradox. No real birthday data is used, collected, or stored. All birthdays shown are simulated for educational purposes only.

Loading calculator...

What You Need to Enter

The birthday paradox simulator needs one number: how many people are in the room. Set a range — say 2 to 60 — and the tool plots the probability of at least one shared birthday at every group size in that range. You can also adjust the number of possible birthdays (default 365) and toggle a Monte Carlo simulation that generates thousands of random trials alongside the exact formula.

Leave the defaults alone for a first run. The curve that appears is the whole point: it climbs far faster than anyone expects, crossing 50% at just 23 people and 99% by 57. Once you see it, change the “days in year” to 100 or 1,000 and watch the threshold shift — that single tweak reveals why the paradox generalizes to hash collisions and cryptographic security.

The Intuition Trap

Most people guess you need about 183 people for a 50% chance of a shared birthday — halfway through 365. That guess feels right but answers the wrong question. It answers “how many people until someone probably shares my birthday?” The actual question is broader: does any pair in the group match?

The difference is enormous. With 23 people there are 23 × 22 / 2 = 253 unique pairs. Each pair has a small chance of matching, but 253 small chances pile up fast. This is complementary counting at work: instead of tracking every possible match, you calculate the probability that nobody shares a birthday and subtract from 1. The first person can land on any of 365 days. The second needs one of the remaining 364. The third needs 363. Multiply all those fractions together and by person 23, the “no match” probability dips just below 0.50 — meaning a match is more likely than not.

The sample space of possible birthday arrangements grows factorially while the number of collision-free arrangements shrinks. That imbalance is why 23 is enough, and why the result shocks even professional mathematicians the first time they see it.

Try This Example

Set the range to 2–60, step size 1, days = 365, and enable the Monte Carlo simulation with 5,000 trials. Hit calculate. Here's what the output looks like for a few key group sizes:

10 people → theory 11.7% sim ≈ 12%
23 people → theory 50.7% sim ≈ 51% ← 50% threshold
30 people → theory 70.6% sim ≈ 71%
40 people → theory 89.1% sim ≈ 89%
57 people → theory 99.0% sim ≈ 99% ← 99% threshold

The simulated column wobbles a point or two each run — that's normal sampling variation. Run 50,000 trials instead of 5,000 and the wobble shrinks. The theoretical column never changes because it's the exact product of fractions, not a random draw.

Now change days to 100 (imagine a planet with a 100-day year). The 50% threshold drops to about 12 people and the 99% threshold to about 31. The critical group size scales roughly as the square root of the number of possible birthdays — √365 ≈ 19, √100 ≈ 10 — which is the same scaling law behind birthday attacks on cryptographic hashes.

What the Math Predicts

The exact formula uses complementary counting. Let D = days in the year and n = people in the room:

P(no match) = (D/D) × ((D−1)/D) × ((D−2)/D) × … × ((D−n+1)/D)
P(at least one match) = 1 − P(no match)
Example: n = 23, D = 365 → P(no match) ≈ 0.493 → P(match) ≈ 0.507

Monte Carlo simulation takes a different route to the same answer. Generate n random integers between 0 and D − 1, check for duplicates, repeat thousands of times, and count what fraction of trials produced a collision. With enough trials the simulated proportion converges to the theoretical value — a live demonstration of the law of large numbers.

There's also a handy approximation: P(no match) ≈ e−n²/(2D). It overestimates the chance of no match slightly, but it's fast for back-of-envelope work. Setting that equal to 0.5 and solving gives n ≈ 1.18√D, which is where the “square root of the number of days” rule of thumb comes from.

Common Mistakes

Asking the wrong question. “Will someone match my birthday?” is not the birthday paradox. That question needs about 253 people for a 50% chance (roughly D × ln 2). The paradox asks about any pair, which involves far more comparisons for the same group size.

Treating the probability as linear. Doubling the group doesn't double the probability. Pairs grow quadratically — 23 people make 253 pairs, 46 people make 1,035 — so the probability curve is an S-shape, not a straight line.

Assuming uniform birthdays matter for the real world. Real birth rates aren't uniform. More babies are born in September than in January in the U.S. Non-uniform distributions actually make collisions more likely, not less. The uniform model is a conservative lower bound, which is useful precisely because it still gives 50% at just 23.

Ignoring leap years. February 29 birthdays are roughly four times rarer than any other date. Including leap day (D = 366 with non-uniform weighting) nudges the 50% threshold down slightly because the non-uniformity increases collision probability. The effect is tiny — less than one person — but it comes up on exams.

Small Questions, Clear Answers

Why is it called a paradox if it's mathematically correct? It's a veridical paradox — a statement that sounds wrong but is provably true. The math is straightforward; it's human intuition that breaks down because we instinctively compare to our own birthday rather than scanning every possible pair.

How does this relate to hash collisions? A hash function maps inputs to a fixed set of outputs, analogous to mapping people to birthdays. The birthday bound tells you that with a hash of length b bits, you expect a collision after roughly 2b/2 inputs — not 2b. That's why 128-bit hashes were retired in favor of 256-bit ones: the effective security is half the bit length.

What happens at 366 people? With 365 possible birthdays and 366 people, the pigeonhole principle guarantees at least one match — probability hits exactly 100%. The simulator confirms this: every single trial finds a duplicate.

Can I use the simulator for a class presentation? Yes. The theoretical values match the standard formula taught in every introductory probability course. Run the simulation live to show Monte Carlo convergence — students remember the wobbling line settling onto the theoretical curve far better than they remember a static equation.

Sources

Frequently Asked Questions

Why is it called a 'paradox'?

It's called a paradox because the result is counterintuitive - most people are surprised to learn that just 23 people are enough for a 50% chance of a shared birthday. The term 'paradox' here doesn't mean a logical contradiction, but rather something that seems absurd yet is mathematically true. The counterintuitive nature comes from confusing 'will someone share MY birthday?' (rare) with 'will ANY two people share a birthday?' (much more likely due to many pairs). Understanding this helps you see why the result is surprising and why it matters.

Do real-world birthdays follow a uniform distribution?

No, real-world birthdays are not perfectly uniform across the year. Some months (like September in the US) have slightly more births than others. However, this doesn't significantly change the birthday paradox - in fact, non-uniform distributions can make collisions even more likely! The uniform assumption is a useful simplification for understanding the core concept. Understanding this helps you see when uniform assumption is appropriate and when real-world distributions may differ.

Does this simulation use real people's data?

Absolutely not. This tool uses purely random numbers generated by your browser. No real birthday data is collected, stored, or transmitted. All 'birthdays' are simply random integers from 0 to (daysInYear-1) generated for educational purposes only. Understanding this helps you see when simulator is appropriate and when it should not be used for actual personal data analysis.

What happens if I change the number of days in a year?

Changing the number of days affects how quickly collisions become likely. With fewer days (like 100), you reach 50% probability with fewer people (approximately 12 people). With more days (like 1000), you need more people (approximately 38 people). Critical group size scales approximately as √D. This lets you explore how the paradox scales - try it with a fictional planet's calendar! Understanding this helps you see how days in year affects probability growth.

Why does the probability grow so fast?

The key insight is that we're not asking 'does someone share MY birthday?' (which would be rare, about 1/365 per person). We're asking 'do ANY two people share a birthday?' With n people, there are n×(n-1)/2 possible pairs to compare. At 23 people, that's 253 pairs! The probability accumulates quickly across all these comparisons. Probability grows approximately quadratically because pairs grow quadratically. Understanding this helps you see why probability grows faster than intuition suggests.

What's the difference between theoretical and simulated results?

The theoretical probability is calculated using the exact mathematical formula: P(shared) = 1 - P(no match), where P(no match) = (D/D) × ((D-1)/D) × ... × ((D-n+1)/D). The simulated probability runs actual random experiments (Monte Carlo simulation) and counts how often a match occurs. They should be very close, but the simulation will have some random variation - that's the nature of randomness! More trials = less variation, more accurate simulation. Understanding this helps you see how to validate theoretical calculations.

Why doesn't 50 people mean 50/365 = 13.7% probability?

This is exactly why the birthday paradox is surprising! The 13.7% calculation assumes each person must match YOUR specific birthday. But the actual question is whether ANY two people match. With 50 people, there are 50×49/2 = 1,225 possible pairs, and the probability that at least one pair matches is about 97%! Understanding this distinction helps you see why birthday paradox is counterintuitive and why pair counting matters.

Can I use this for cryptographic hash collisions?

The birthday paradox does apply to hash functions - it's why cryptographic hashes need to be long enough to prevent 'birthday attacks.' However, this educational tool is not designed for security analysis. For real cryptographic applications, consult security professionals and use established standards. Understanding this helps you see when birthday paradox applies to computer science and when professional security analysis is needed.

What are the critical group sizes (50% and 99% thresholds)?

Critical group sizes are the smallest group sizes reaching specific probability thresholds. For 365 days: Critical50 (50% probability) is approximately 23 people, Critical99 (99% probability) is approximately 57 people. These scale approximately as √D with days in year. Understanding critical group sizes helps you see key milestones in probability growth and why these thresholds are important.

What is the pigeonhole principle and how does it apply?

The pigeonhole principle states that if you have more items than containers, at least one container must have multiple items. For birthdays: if you have 366+ people (more than days in year), at least two must share a birthday - probability becomes 100%. This is guaranteed, not probabilistic. Understanding pigeonhole principle helps you see why probability reaches 100% when group size exceeds days in year.

Related Probability & Statistics Tools

Disclaimer: This simulator is for educational and entertainment purposes only. It uses random number generation to demonstrate probability concepts. No real personal birthday data is involved. For questions about probability and statistics, consult educational resources or qualified instructors.

How helpful was this calculator?

Birthday Paradox Simulator: 23 People, 50% Match