Birthday paradox calculator
How likely is it that two people in a group share a birthday? Exact odds, people needed, and hash collisions.
365 for birthdays. For hash or ID collisions, enter the number of possible values (for example 4294967296) or switch to bits (for example 32).
How do you calculate the birthday paradox?
Find the chance that all n birthdays are different and subtract it from 1: P = 1 − 365 × 364 × … × (365 − n + 1) ÷ 365ⁿ = 1 − 365! ÷ ((365 − n)! × 365ⁿ). For 23 people the chance that nobody shares a birthday is 0.4927028, so the chance of at least one shared birthday is 50.73% (Grinstead and Snell, Introduction to Probability, table 3.1). With 22 people it is 47.57%.
Why does it take so few people?
Because it is pairs that matter, not people. Among 23 people there are 23 × 22 ÷ 2 = 253 pairs, and each pair has a 1 in 365 chance of matching, so the expected number of matching pairs is n(n − 1) ÷ (2 × 365) = 253 ÷ 365 = 0.69. The chance climbs quickly after that: 99.0% with 57 people, 99.9% with 70 and 99.99997% with 100.
How many people do I need for a given chance?
The smallest groups with at least 50%, 75%, 90%, 95%, 99% and 99.9% chance of a shared birthday are 23, 32, 41, 47, 57 and 70 people. Use the “People for a chance” mode for any other target, or for a year with a different number of days.
What is the chance that someone shares my birthday?
That is a different question. For n other people it is 1 − (364 ÷ 365)ⁿ, and it takes 253 other people to pass 50% (1 − (364/365)²⁵³ = 50.05%). With 23 people it is only 6.1%. The chance that some pair matches is much higher than the chance that a particular person matches yours.
What about hash collisions and other pools of values?
Replace 365 with N, the number of equally likely values (for a b-bit hash, N = 2^b; choose “Bits” to enter b). The exact product still works, and the chance of a match is close to 1 − e^(−n(n − 1) ÷ 2N). The 50% point is near √(2N × ln 2) ≈ 1.1774 × √N values: about 77,000 for 32 bits (the exact product puts the first n above 50% at 77,164) and about 5.1 billion for 64 bits (5,056,937,541).
What does this calculator assume?
That every day (or value) is equally likely, that people are independent, and that a year has exactly the number of days you enter — by default 365, so February 29 and twins are ignored. Real birth rates are not perfectly uniform; Grinstead and Snell note that uneven rates make a shared birthday even more likely, so the equal-days answer, if anything, understates the chance.
Sources: C. M. Grinstead and J. L. Snell, Introduction to Probability, chapter 3, section 3.1 (Example 3.3, tables 3.1 and 3.2); Wikipedia, “Birthday problem” and “Birthday attack” (the √(2N ln 2) rule and hash-size examples). Related: probability calculator, permutation and combination calculator, binomial probability calculator and factorial calculator.