HomeStatistics & Probability › Birthday Problem Calculator

Birthday Problem Calculator

Computes the probability that at least two of n people share a birthday in a year of a given length (365 days by default), the complementary probability that all birthdays differ, the expected number of matching pairs, and the group sizes at which the chance reaches 50 % and 99 %.

When to use

You want the classic birthday-paradox probability for a group, or the same collision probability for any set of equally likely categories (hash values, PINs, tokens).

Do not use when: You want the probability that someone shares a specific person's birthday (that is 1 − (364/365)^(n−1), a different question), or birthdays are far from uniform.

Formula

P(all different) = Π_{i=0}^{people−1} (1 − i/days) = days! / ((days − people)! · days^people); P(shared) = 1 − P(all different); expected pairs = people·(people − 1) / (2·days)

Assumes birthdays are independent and uniformly distributed over the days. With more people than days the probability is exactly 1 (pigeonhole principle). Real birthdays are slightly non-uniform, which raises the probability marginally.

Inputs

ParameterTypeUnitRequiredDescription
peopleintegeryesSize of the group. Range: ≥ 1, ≤ 100000
daysintegerdefault 365Number of equally likely birthdays or categories (365 ignores leap days; use 366 to include them). Range: ≥ 1, ≤ 1000000

Outputs

OutputTypeUnitDescription
probability_sharednumber1 − P(all different).
probability_shared_percentnumber%Same probability in percent.
probability_all_differentnumberΠ_{i=0}^{n−1} (1 − i/days).
expected_matching_pairsnumberC(n, 2) / days: expected number of pairs sharing a birthday.
people_for_50_percentintegerSmallest group with at least a 50 % chance of a shared birthday.
people_for_99_percentintegerSmallest group with at least a 99 % chance.

Example

23 people: {"people":23}{"probability_shared":0.507297,"probability_shared_percent":50.73,"probability_all_different":0.492703,"expected_matching_pairs":0.6932,"people_for_50_percent":23,"people_for_99_percent":57}

30 people: {"people":30,"days":365}{"probability_shared":0.706316,"probability_shared_percent":70.63,"expected_matching_pairs":1.1918}

GET https://tttkmbb.com/api/v1/calculate/birthday-problem?people=23

Machine access

Sources

FAQ

Why only 23 people for a 50 % chance?

There are C(23, 2) = 253 pairs of people, and each pair has a 1/365 chance of matching; it is the number of pairs, not the number of people, that grows quickly.

What about leap years?

Set days = 366 to include 29 February as an equally likely day; the effect on the probability is tiny (50.63 % instead of 50.73 % for 23 people).

Related calculators