Birthday problem
{{Short description|Probability of shared birthdays}}
{{for-multi|yearly variation in mortality rates|Birthday effect|the mathematical brain teaser that was asked in the Math Olympiad|Cheryl's Birthday}}
In probability theory, the birthday problem asks for the probability that, in a set of {{mvar|n}} randomly chosen people, at least two will share the same birthday. The birthday paradox is the counterintuitive fact that only 23 people are needed for that probability to exceed 50%.
The birthday paradox is a veridical paradox: it seems wrong at first glance but is, in fact, true. While it may seem surprising that only 23 individuals are required to reach a 50% probability of a shared birthday, this result is made more intuitive by considering that the birthday comparisons will be made between every possible pair of individuals. With 23 individuals, there are {{sfrac|23 × 22|2}} = 253 pairs to consider.
Real-world applications for the birthday problem include a cryptographic attack called the birthday attack, which uses this probabilistic model to reduce the complexity of finding a collision for a hash function, as well as calculating the approximate risk of a hash collision existing within the hashes of a given size of population.
The problem is generally attributed to Harold Davenport in about 1927, though he did not publish it at the time. Davenport did not claim to be its discoverer "because he could not believe that it had not been stated earlier".David Singmaster, Sources in Recreational Mathematics: An Annotated Bibliography, Eighth Preliminary Edition, 2004, [https://www.puzzlemuseum.com/singma/singma6/SOURCES/singma-sources-edn8-2004-03-19.htm#_Toc69534221 section 8.B]H.S.M. Coxeter, "Mathematical Recreations and Essays, 11th edition", 1940, p 45, as reported in I. J. Good, Probability and the weighing of evidence, 1950, [https://archive.org/details/probabilityweigh0000good/page/38/mode/2up?q=same%20birthday p. 38] The first publication of a version of the birthday problem was by Richard von Mises in 1939.Richard Von Mises, "Über Aufteilungs- und Besetzungswahrscheinlichkeiten", Revue de la faculté des sciences de l'Université d'Istanbul 4:145-163, 1939, reprinted in {{cite book |editor-first1 = P. |editor-last1 = Frank |editor-first2 = S. |editor-last2 = Goldstein |editor-first3 = M. |editor-last3 = Kac |editor-first4 = W. |editor-last4 = Prager |editor-first5 = G. |editor-last5 = Szegö |editor-first6 = G. |editor-last6 = Birkhoff |title = Selected Papers of Richard von Mises |volume = 2 | pages = 313–334 |date=1964 |publisher = Amer. Math. Soc. |location=Providence, Rhode Island}}
Calculating the probability
From a permutations perspective, let the event {{math|A}} be the probability of finding a group of 23 people without any repeated birthdays. And let the event {{math|B}} be the probability of finding a group of 23 people with at least two people sharing same birthday, {{math|P(B) {{=}} 1 − P(A)}}. This is such that {{math|P(A)}} is the ratio of the total number of birthdays, , without repetitions and order matters (e.g. for a group of 2 people, mm/dd birthday format, one possible outcome is ) divided by the total number of birthdays with repetition and order matters, , as it is the total space of outcomes from the experiment (e.g. 2 people, one possible outcome is ). Therefore and are permutations.
:
Another way the birthday problem can be solved is by asking for an approximate probability that in a group of {{mvar|n}} people at least two have the same birthday. For simplicity, leap years, twins, selection bias, and seasonal and weekly variations in birth rates{{refn|see Birthday#Distribution through the year}} are generally disregarded, and instead it is assumed that there are 365 possible birthdays, and that each person's birthday is equally likely to be any of these days, independent of the other people in the group.
For independent birthdays, a uniform distribution of birthdays minimizes the probability of two people in a group having the same birthday. Any unevenness increases the likelihood of two people sharing a birthday.{{Harv|Bloom|1973}}{{cite book |author-first = J. Michael |author-last = Steele |title = The Cauchy‑Schwarz Master Class |url = https://archive.org/details/cauchyschwarzmas00stee_431 |url-access = limited | pages = [https://archive.org/details/cauchyschwarzmas00stee_431/page/n217 206], 277 |date=2004 |publisher = Cambridge University Press |location=Cambridge | isbn = 9780521546775 }} However real-world birthdays are not sufficiently uneven to make much change: the real-world group size necessary to have a greater than 50% chance of a shared birthday is 23, as in the theoretical uniform distribution.{{cite journal |author1 = Mario Cortina Borja |author2 = John Haigh |title = The Birthday Problem |journal = Significance |date = September 2007 |volume = 4 |issue = 3 |pages = 124–127 |publisher = Royal Statistical Society |doi = 10.1111/j.1740-9713.2007.00246.x|doi-access = free }}
The goal is to compute {{math|P(B)}}, the probability that at least two people in the room have the same birthday. However, it is simpler to calculate {{math|P(A′)}}, the probability that no two people in the room have the same birthday. Then, because {{math|B}} and {{math|A′}} are the only two possibilities and are also mutually exclusive, {{math|P(B) {{=}} 1 − P(A′).}}
Here is the calculation of {{math|P(B)}} for 23 people. Let the 23 people be numbered 1 to 23. The event that all 23 people have different birthdays is the same as the event that person 2 does not have the same birthday as person 1, and that person 3 does not have the same birthday as either person 1 or person 2, and so on, and finally that person 23 does not have the same birthday as any of persons 1 through 22. Let these events be called Event 2, Event 3, and so on. Event 1 is the event of person 1 having a birthday, which occurs with probability 1. This conjunction of events may be computed using conditional probability: the probability of Event 2 is {{sfrac|364|365}}, as person 2 may have any birthday other than the birthday of person 1. Similarly, the probability of Event 3 given that Event 2 occurred is {{sfrac|363|365}}, as person 3 may have any of the birthdays not already taken by persons 1 and 2. This continues until finally the probability of Event 23 given that all preceding events occurred is {{sfrac|343|365}}. Finally, the principle of conditional probability implies that {{math|P(A′)}} is equal to the product of these individual probabilities:
{{NumBlk|:||{{EquationRef|1}}}}
The terms of equation ({{EquationNote|1}}) can be collected to arrive at:
{{NumBlk|:||{{EquationRef|2}}}}
Evaluating equation ({{EquationNote|2}}) gives {{math|P(A′) ≈ 0.492703}}
Therefore, {{math|P(B) ≈ 1 − 0.492703 {{=}} 0.507297}} (50.7297%).
This process can be generalized to a group of {{mvar|n}} people, where {{math|p(n)}} is the probability of at least two of the {{mvar|n}} people sharing a birthday. It is easier to first calculate the probability {{math|{{overline|p}}(n)}} that all {{mvar|n}} birthdays are different. According to the pigeonhole principle, {{math|{{overline|p}}(n)}} is zero when {{math|n > 365}}. When {{math|n ≤ 365}}:
:
where {{math|!}} is the factorial operator, {{math|{{pars|s=160%|{{su|p=365|b=n|a=c}}}}}} is the binomial coefficient and {{math|kPr}} denotes permutation.
The equation expresses the fact that the first person has no one to share a birthday, the second person cannot have the same birthday as the first {{math|{{pars|s=160%|{{sfrac|364|365}}}}}}, the third cannot have the same birthday as either of the first two {{math|{{pars|s=160%|{{sfrac|363|365}}}}}}, and in general the {{mvar|n}}th birthday cannot be the same as any of the {{math|n − 1}} preceding birthdays.
The event of at least two of the {{mvar|n}} persons having the same birthday is complementary to all {{mvar|n}} birthdays being different. Therefore, its probability {{math|p(n)}} is
:
The following table shows the probability for some other values of {{mvar|n}} (for this table, the existence of leap years is ignored, and each birthday is assumed to be equally likely):
:
class="wikitable"
!{{mvar|n}}!!{{math|p(n)}} | |
align=right|1 | {{0}}0.0% |
align=right|5 | {{0}}2.7% |
align=right|10 | 11.7% |
align=right|20 | 41.1% |
align=right|23 | 50.7% |
align=right|30 | 70.6% |
align=right|40 | 89.1% |
align=right|50 | 97.0% |
align=right|60 | 99.4% |
align=right|70 | 99.9% |
align=right|75 | 99.97% |
align=right|100 | {{val|99.99997}}% |
align=right|200 | {{val|99.9999999999999999999999999998}}% |
align=right|300 | (100 − {{val|6|e=-80}})% |
align=right|350 | (100 − {{val|3|e=-129}})% |
align=right|365 | (100 − {{val|1.45|e=-155}})% |
align=right|≥ 366 | 100% |
Approximations
Image:Birthday paradox probability.svg
Image:Birthday paradox approximation.svg
The Taylor series expansion of the exponential function (the constant {{math|e ≈ {{val|2.718281828}}}})
:
provides a first-order approximation for {{math|ex}} for :
:
To apply this approximation to the first expression derived for {{math|{{overline|p}}(n)}}, set {{math|x {{=}} −{{sfrac|a|365}}}}. Thus,
:
Then, replace {{mvar|a}} with non-negative integers for each term in the formula of {{math|{{overline|p}}(n)}} until {{math|a {{=}} n − 1}}, for example, when {{math|a {{=}} 1}},
:
The first expression derived for {{math|{{overline|p}}(n)}} can be approximated as
:
\begin{align}
\bar p(n) & \approx 1 \cdot e^{-1/365} \cdot e^{-2/365} \cdots e^{-(n-1)/365} \\[6pt]
& = e^{-\big(1+2+ \,\cdots\, +(n-1)\big)/365} \\[6pt]
& = e^{-\frac{n(n-1)/2}{365}} = e^{-\frac{n(n-1)}{730}}.
\end{align}
Therefore,
:
An even coarser approximation is given by
:
which, as the graph illustrates, is still fairly accurate.
According to the approximation, the same approach can be applied to any number of "people" and "days". If rather than 365 days there are {{mvar|d}}, if there are {{mvar|n}} persons, and if {{math|n ≪ d}}, then using the same approach as above we achieve the result that if {{math|p(n, d)}} is the probability that at least two out of {{mvar|n}} people share the same birthday from a set of {{mvar|d}} available days, then:
:
p(n, d) & \approx 1-e^{-\frac{n(n-1)}{2d}} \\[6pt]
& \approx 1-e^{-\frac{n^2}{2d}}.
\end{align}
=Simple exponentiation=
The probability of any two people not having the same birthday is {{sfrac|364|365}}. In a room containing n people, there are {{math|{{pars|s=150%|{{su|p=n|b=2|a=c}}}} {{=}} {{sfrac|n(n − 1)|2}}}} pairs of people, i.e. {{math|{{pars|s=150%|{{su|p=n|b=2|a=c}}}}}} events. The probability of no two people sharing the same birthday can be approximated by assuming that these events are independent and hence by multiplying their probability together. Being independent would be equivalent to picking with replacement, any pair of people in the world, not just in a room. In short {{sfrac|364|365}} can be multiplied by itself {{math|{{pars|s=150%|{{su|p=n|b=2|a=c}}}}}} times, which gives us
:
Since this is the probability of no one having the same birthday, then the probability of someone sharing a birthday is
:
And for the group of 23 people, the probability of sharing is
:
=Poisson approximation=
Applying the Poisson approximation for the binomial on the group of 23 people,
:
so
:
The result is over 50% as previous descriptions. This approximation is the same as the one above based on the Taylor expansion that uses {{math|ex ≈ 1 + x}}.
=Square approximation=
A good rule of thumb which can be used for mental calculation is the relation
:
which can also be written as
:
which works well for probabilities less than or equal to {{sfrac|1|2}}. In these equations, {{mvar|d}} is the number of days in a year.
For instance, to estimate the number of people required for a {{sfrac|1|2}} chance of a shared birthday, we get
:
Which is not too far from the correct answer of 23.
=Approximation of number of people=
This can also be approximated using the following formula for the number of people necessary to have at least a {{sfrac|1|2}} chance of matching:
:
This is a result of the good approximation that an event with {{math|{{sfrac|1|k}}}} probability will have a {{sfrac|1|2}} chance of occurring at least once if it is repeated {{math|k ln 2}} times.{{cite journal
| last = Mathis
| first = Frank H.
|date= June 1991
| title = A Generalized Birthday Problem
| journal = SIAM Review
| volume = 33
| issue = 2
| pages = 265–270
| issn = 0036-1445
| doi = 10.1137/1033051
| oclc = 37699182
| jstor = 2031144
| url = http://http.cs.berkeley.edu/~daw/papers/genbday-crypto02.ps
}}
=Probability table=
{{Main|Birthday attack}}
:
class="wikitable" style="white-space:nowrap;" |
rowspan="2" | length of hex string ! rowspan="2" | no. of ! rowspan="2" | hash space ! colspan="10" | Number of hashed elements such that probability of at least one hash collision ≥ {{mvar|p}} |
---|
{{mvar|p}} = {{val||e=-18}}
! {{mvar|p}} = {{val||e=-15}} ! {{mvar|p}} = {{val||e=-12}} ! {{mvar|p}} = {{val||e=-9}} ! {{mvar|p}} = {{val||e=-6}} ! {{mvar|p}} = 0.001 ! {{mvar|p}} = 0.01 ! {{mvar|p}} = 0.25 ! {{mvar|p}} = 0.50 ! {{mvar|p}} = 0.75 |
align="center"
| bgcolor="#F2F2F2" | 8 | bgcolor="#F2F2F2" | 32 | bgcolor="#F2F2F2" | {{val|4.3|e=9}} | 2 | 2 | 2 | 2.9 | 93 | {{val|2.9|e=3}} | {{val|9.3|e=3}} | {{val|5.0|e=4}} | {{val|7.7|e=4}} | {{val|1.1|e=5}} |
align="center"
| bgcolor="#F2F2F2" | (10) | bgcolor="#F2F2F2" | (40) | bgcolor="#F2F2F2" | ({{val|1.1|e=12}}) | 2 | 2 | 2 | 47 | {{val|1.5|e=3}} | {{val|4.7|e=4}} | {{val|1.5|e=5}} | {{val|8.0|e=5}} | {{val|1.2|e=6}} | {{val|1.7|e=6}} |
align="center"
| bgcolor="#F2F2F2" | (12) | bgcolor="#F2F2F2" | (48) | bgcolor="#F2F2F2" | ({{val|2.8|e=14}}) | 2 | 2 | 24 | {{val|7.5|e=2}} | {{val|2.4|e=4}} | {{val|7.5|e=5}} | {{val|2.4|e=6}} | {{val|1.3|e=7}} | {{val|2.0|e=7}} | {{val|2.8|e=7}} |
align="center"
| bgcolor="#F2F2F2" | 16 | bgcolor="#F2F2F2" | 64 | bgcolor="#F2F2F2" | {{val|1.8|e=19}} | 6.1 | {{val|1.9|e=2}} | {{val|6.1|e=3}} | {{val|1.9|e=5}} | {{val|6.1|e=6}} | {{val|1.9|e=8}} | {{val|6.1|e=8}} | {{val|3.3|e=9}} | {{val|5.1|e=9}} | {{val|7.2|e=9}} |
align="center"
| bgcolor="#F2F2F2" | (24) | bgcolor="#F2F2F2" | (96) | bgcolor="#F2F2F2" | ({{val|7.9|e=28}}) | {{val|4.0|e=5}} | {{val|1.3|e=7}} | {{val|4.0|e=8}} | {{val|1.3|e=10}} | {{val|4.0|e=11}} | {{val|1.3|e=13}} | {{val|4.0|e=13}} | {{val|2.1|e=14}} | {{val|3.3|e=14}} | {{val|4.7|e=14}} |
align="center"
| bgcolor="#F2F2F2" | 32 | bgcolor="#F2F2F2" | 128 | bgcolor="#F2F2F2" | {{val|3.4|e=38}} | {{val|2.6|e=10}} | {{val|8.2|e=11}} | {{val|2.6|e=13}} | {{val|8.2|e=14}} | {{val|2.6|e=16}} | {{val|8.3|e=17}} | {{val|2.6|e=18}} | {{val|1.4|e=19}} | {{val|2.2|e=19}} | {{val|3.1|e=19}} |
align="center"
| bgcolor="#F2F2F2" | (48) | bgcolor="#F2F2F2" | (192) | bgcolor="#F2F2F2" | ({{val|6.3|e=57}}) | {{val|1.1|e=20}} | {{val|3.5|e=21}} | {{val|1.1|e=23}} | {{val|3.5|e=24}} | {{val|1.1|e=26}} | {{val|3.5|e=27}} | {{val|1.1|e=28}} | {{val|6.0|e=28}} | {{val|9.3|e=28}} | {{val|1.3|e=29}} |
align="center"
| bgcolor="#F2F2F2" | 64 | bgcolor="#F2F2F2" | 256 | bgcolor="#F2F2F2" | {{val|1.2|e=77}} | {{val|4.8|e=29}} | {{val|1.5|e=31}} | {{val|4.8|e=32}} | {{val|1.5|e=34}} | {{val|4.8|e=35}} | {{val|1.5|e=37}} | {{val|4.8|e=37}} | {{val|2.6|e=38}} | {{val|4.0|e=38}} | {{val|5.7|e=38}} |
align="center"
| bgcolor="#F2F2F2" | (96) | bgcolor="#F2F2F2" | (384) | bgcolor="#F2F2F2" | ({{val|3.9|e=115}}) | {{val|8.9|e=48}} | {{val|2.8|e=50}} | {{val|8.9|e=51}} | {{val|2.8|e=53}} | {{val|8.9|e=54}} | {{val|2.8|e=56}} | {{val|8.9|e=56}} | {{val|4.8|e=57}} | {{val|7.4|e=57}} | {{val|1.0|e=58}} |
align="center"
| bgcolor="#F2F2F2" | 128 | bgcolor="#F2F2F2" | 512 | bgcolor="#F2F2F2" | {{val|1.3|e=154}} | {{val|1.6|e=68}} | {{val|5.2|e=69}} | {{val|1.6|e=71}} | {{val|5.2|e=72}} | {{val|1.6|e=74}} | {{val|5.2|e=75}} | {{val|1.6|e=76}} | {{val|8.8|e=76}} | {{val|1.4|e=77}} | {{val|1.9|e=77}} |
[[File:birthday_attack_vs_paradox.svg|thumb|Comparison of the birthday problem (1) and birthday attack (2):{{parabreak}}
In (1), collisions are found within one set, in this case, 3 out of 276 pairings of the 24 lunar astronauts.{{parabreak}}
In (2), collisions are found between two sets, in this case, 1 out of 256 pairings of only the first bytes of SHA-256 hashes of 16 variants each of benign and harmful contracts.]]
The lighter fields in this table show the number of hashes needed to achieve the given probability of collision (column) given a hash space of a certain size in bits (row). Using the birthday analogy: the "hash space size" resembles the "available days", the "probability of collision" resembles the "probability of shared birthday", and the "required number of hashed elements" resembles the "required number of people in a group". One could also use this chart to determine the minimum hash size required (given upper bounds on the hashes and probability of error), or the probability of collision (for fixed number of hashes and probability of error).
For comparison, {{val|e=-18}} to {{val|e=-15}} is the uncorrectable bit error rate of a typical hard disk.Jim Gray, Catharine van Ingen. [https://arxiv.org/abs/cs/0701166 Empirical Measurements of Disk Failure Rates and Error Rates] In theory, 128-bit hash functions, such as MD5, should stay within that range until about {{val|8.2|e=11}} documents, even if its possible outputs are many more.
An upper bound on the probability and a lower bound on the number of people
The argument below is adapted from an argument of Paul Halmos.{{refn|group=nb|In his autobiography, Halmos criticized the form in which the birthday paradox is often presented, in terms of numerical computation. He believed that it should be used as an example in the use of more abstract mathematical concepts. He wrote:
The reasoning is based on important tools that all students of mathematics should have ready access to. The birthday problem used to be a splendid illustration of the advantages of pure thought over mechanical manipulation; the inequalities can be obtained in a minute or two, whereas the multiplications would take much longer, and be much more subject to error, whether the instrument is a pencil or an old-fashioned desk computer. What calculators do not yield is understanding, or mathematical facility, or a solid basis for more advanced, generalized theories.}}
As stated above, the probability that no two birthdays coincide is
:
As in earlier paragraphs, interest lies in the smallest {{mvar|n}} such that {{math|p(n) > {{sfrac|1|2}}}}; or equivalently, the smallest {{mvar|n}} such that {{math|{{overline|p}}(n) < {{sfrac|1|2}}}}.
Using the inequality {{math|1 − x < e−x}} in the above expression we replace {{math|1 − {{sfrac|k|365}}}} with {{math|e{{frac|−k|365}}}}. This yields
:
Therefore, the expression above is not only an approximation, but also an upper bound of {{math|{{overline|p}}(n)}}. The inequality
:
implies {{math|{{overline|p}}(n) < {{sfrac|1|2}}}}. Solving for {{mvar|n}} gives
:
Now, {{math|730 ln 2}} is approximately 505.997, which is barely below 506, the value of {{math|n2 − n}} attained when {{math|n {{=}} 23}}. Therefore, 23 people suffice. Incidentally, solving {{math|n2 − n {{=}} 730 ln 2}} for n gives the approximate formula of Frank H. Mathis cited above.
This derivation only shows that at most 23 people are needed to ensure the chances of a birthday match are at least even; it leaves open the possibility that {{mvar|n}} is 22 or less could also work.
Generalizations
=Arbitrary number of days=
Given a year with {{mvar|d}} days, the generalized birthday problem asks for the minimal number {{math|n(d)}} such that, in a set of {{mvar|n}} randomly chosen people, the probability of a birthday coincidence is at least 50%. In other words, {{math|n(d)}} is the minimal integer {{mvar|n}} such that
:
The classical birthday problem thus corresponds to determining {{math|n(365)}}. The first 99 values of {{math|n(d)}} are given here {{OEIS|id=A033810}}:
:
class="wikitable" style="text-align:center;" |
scope="row" | {{mvar|d}}
| 1–2 || 3–5 || 6–9 || 10–16 || 17–23 || 24–32 || 33–42 || 43–54 || 55–68 || 69–82 || 83–99 |
---|
scope="row" | {{math|n(d)}}
| 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 |
A similar calculation shows that {{math|n(d)}} = 23 when {{mvar|d}} is in the range 341–372.
A number of bounds and formulas for {{math|n(d)}} have been published.{{wikicite|ref={{Harvid|Brink|2012}}|reference=D. Brink, A (probably) exact solution to the Birthday Problem, Ramanujan Journal, 2012, [https://link.springer.com/article/10.1007/s11139-011-9343-9].}}
For any {{math|d ≥ 1}}, the number {{math|n(d)}} satisfies{{Harvard citations|author=Brink|year=2012|nb=yes|loc=Theorem 2}}
:
These bounds are optimal in the sense that the sequence {{math|n(d) − {{sqrt|2d ln 2}}}}
gets arbitrarily close to
:
while it has
:
as its maximum, taken for {{math|d {{=}} 43}}.
The bounds are sufficiently tight to give the exact value of {{math|n(d)}} in most of the cases. For example, for {{math|d {{=}}}} 365 these bounds imply that {{math|22.7633 < n(365) < 23.7736}} and 23 is the only integer in that range. In general, it follows from these bounds that {{math|n(d)}} always equals either
:
where {{math|⌈ · ⌉}} denotes the ceiling function.
The formula
:
holds for 73% of all integers {{mvar|d}}.{{Harvard citations|author=Brink|year=2012|nb=yes|loc=Theorem 3}} The formula
:
holds for almost all {{mvar|d}}, i.e., for a set of integers {{mvar|d}} with asymptotic density 1.
The formula
:
holds for all {{math|d ≤ {{val|e=18}}}}, but it is conjectured that there are infinitely many counterexamples to this formula.{{Harvard citations|author=Brink|year=2012|nb=yes|loc=Table 3, Conjecture 1}}
The formula
:
holds for all {{math|d ≤ {{val|e=18}}}}, and it is conjectured that this formula holds for all {{mvar|d}}.
=More than two people sharing a birthday=
It is possible to extend the problem to ask how many people in a group are necessary for there to be a greater than 50% probability that at least 3, 4, 5, etc. of the group share the same birthday.
The first few values are as follows: >50% probability of 3 people sharing a birthday - 88 people; >50% probability of 4 people sharing a birthday - 187 people {{OEIS|A014088}}.{{cite web |title=Minimal number of people to give a 50% probability of having at least n coincident birthdays in one year. |url=https://oeis.org/A014088 |website=The On-line Encyclopedia of Integer Sequences |publisher=OEIS |access-date=17 February 2020}}
==Probability of a unique collision==
The classic birthday problem allows for more than two people to share a particular birthday or for there to be matches on multiple days. The probability that among {{mvar|n}} people there is exactly one pair of individuals with a matching birthday given {{mvar|d}} possible days is
:
Unlike the standard birthday problem, as {{mvar|n}} increases the probability reaches a maximum value before decreasing. For example, for {{math|d {{=}} 365}}, the probability of a unique match has a maximum value of 0.3864 occurring when {{math|n {{=}} 28}}.
==Generalization to multiple types of people==
The basic problem considers all trials to be of one "type". The birthday problem has been generalized to consider an arbitrary number of types.M. C. Wendl (2003) [https://dx.doi.org/10.1016/S0167-7152(03)00168-8 Collision Probability Between Sets of Random Variables], Statistics and Probability Letters 64(3), 249–254. In the simplest extension there are two types of people, say {{mvar|m}} men and {{mvar|n}} women, and the problem becomes characterizing the probability of a shared birthday between at least one man and one woman. (Shared birthdays between two men or two women do not count.) The probability of no shared birthdays here is
:
where {{math|d {{=}} 365}} and {{math|S2}} are Stirling numbers of the second kind. Consequently, the desired probability is {{math|1 − p0}}.
This variation of the birthday problem is interesting because there is not a unique solution for the total number of people {{math|m + n}}. For example, the usual 50% probability value is realized for both a 32-member group of 16 men and 16 women and a 49-member group of 43 women and 6 men.
Other birthday problems
=First match=
A related question is, as people enter a room one at a time, which one is most likely to be the first to have the same birthday as someone already in the room? That is, for what {{mvar|n}} is {{math|p(n) − p(n − 1)}} maximum? The answer is 20—if there is a prize for first match, the best position in line is 20th.{{citation needed|date=September 2019}}
=Same birthday as you=
In the birthday problem, neither of the two people is chosen in advance. By contrast, the probability {{math|q(n)}} that at least one other person in a room of {{mvar|n}} other people has the same birthday as a particular person (for example, you) is given by
:
and for general {{mvar|d}} by
:
In the standard case of {{math|d {{=}} 365}}, substituting {{math|n {{=}} 23}} gives about 6.1%, which is less than 1 chance in 16. For a greater than 50% chance that at least one other person in a roomful of {{mvar|n}} people has the same birthday as you, {{mvar|n}} would need to be at least 253. This number is significantly higher than {{math|{{sfrac|365|2}} {{=}} 182.5}}: the reason is that it is likely that there are some birthday matches among the other people in the room.
= Number of people until every birthday is achieved =
The expected number of people needed until every birthday is achieved is called the Coupon collector's problem. It can be calculated by {{math|nHn}}, where {{math|Hn}} is the {{mvar|n}}th harmonic number. For 365 possible dates (the birthday problem), the answer is 2365.
=Near matches=
Another generalization is to ask for the probability of finding at least one pair in a group of {{mvar|n}} people with birthdays within {{mvar|k}} calendar days of each other, if there are {{mvar|d}} equally likely birthdays.M. Abramson and W. O. J. Moser (1970) More Birthday Surprises, American Mathematical Monthly 77, 856–858
:
The number of people required so that the probability that some pair will have a birthday separated by {{mvar|k}} days or fewer will be higher than 50% is given in the following table:
:
class="wikitable" style="text-align: center"
! {{mvar|k}} !! {{mvar|n}} | |
0 | 23 |
1 | 14 |
2 | 11 |
3 | 9 |
4 | 8 |
5 | 8 |
6 | 7 |
7 | 7 |
Thus in a group of just seven random people, it is more likely than not that two of them will have a birthday within a week of each other.
= Number of days with a certain number of birthdays =
== Number of days with at least one birthday ==
The expected number of different birthdays, i.e. the number of days that are at least one person's birthday, is:
:
This follows from the expected number of days that are no one's birthday:
:
which follows from the probability that a particular day is no one's birthday, {{math|{{pars|s=150%|{{sfrac|d − 1|d}}}}{{su|p=n|b= }}}}, easily summed because of the linearity of the expected value.
For instance, with {{math|1={{var|d}} = 365}}, you should expect about 21 different birthdays when there are 22 people, or 46 different birthdays when there are 50 people. When there are 1000 people, there will be around 341 different birthdays (24 unclaimed birthdays).
== Number of days with at least two birthdays ==
The above can be generalized from the distribution of the number of people with their birthday on any particular day, which is a Binomial distribution with probability {{math|{{sfrac|1|d}}}}. Multiplying the relevant probability by {{mvar|d}} will then give the expected number of days. For example, the expected number of days which are shared; i.e. which are at least two (i.e. not zero and not one) people's birthday is:
=Number of people who repeat a birthday=
The probability that the {{mvar|k}}th integer randomly chosen from {{math|[1,d]}} will repeat at least one previous choice equals {{math|q(k − 1; d)}} above. The expected total number of times a selection will repeat a previous selection as {{mvar|n}} such integers are chosen equals{{cite web|last1=Might|first1=Matt|title=Collision hash collisions with the birthday paradox|url=http://matt.might.net/articles/counting-hash-collisions/|website=Matt Might's blog|access-date=17 July 2015}}
:
This can be seen to equal the number of people minus the expected number of different birthdays.
=Reverse problem=
The reverse problem is to find, for a fixed probability {{mvar|p}},
the greatest {{mvar|n}} for which the probability {{math|p(n)}} is smaller than the given {{mvar|p}}, or the smallest {{mvar|n}} for which the probability {{math|p(n)}} is greater than the given {{mvar|p}}.{{citation needed|date=September 2019}}
Taking the above formula for {{math|d {{=}} 365}}, one has
:
The following table gives some sample calculations.
:
class="wikitable" | ||||
----
! {{mvar|p}} | {{mvar|n}}
! {{math|n↓}} | {{math|p(n↓)}} | {{math|n↑}} | {{math|p(n↑)}} |
----
| 0.01 | 0.14178{{sqrt|365}} = 2.70864 | align="right" | 2 | 0.00274 | align="right" | 3
| 0.00820 | ||
----
| 0.05 | 0.32029{{sqrt|365}} = 6.11916
| align="right" | 6 | 0.04046 | align="right" | 7 | 0.05624 |
----
| 0.1 | 0.45904{{sqrt|365}} = 8.77002 | align="right" | 8 | 0.07434 | align="right" | 9
| 0.09462 | ||
----
| 0.2 | 0.66805{{sqrt|365}} = 12.76302 | align="right" | 12 | 0.16702 | align="right" | 13
| 0.19441 | ||
----
| 0.3 | 0.84460{{sqrt|365}} = 16.13607
| align="right" | 16 | 0.28360 | align="right" | 17 | 0.31501 |
----
| 0.5 | 1.17741{{sqrt|365}} = 22.49439
| align="right" | 22 | 0.47570 | align="right" | 23 | 0.50730 |
----
| 0.7 | 1.55176{{sqrt|365}} = 29.64625
| align="right" | 29 | 0.68097 | align="right" | 30 | 0.70632 |
----
| 0.8 | 1.79412{{sqrt|365}} = 34.27666
| align="right" | 34 | 0.79532 | align="right" | 35 | 0.81438 |
----
| 0.9 | 2.14597{{sqrt|365}} = 40.99862
| align="right" | 40 | 0.89123 | align="right" | 41 | 0.90315 |
----
| 0.95 | 2.44775{{sqrt|365}} = 46.76414
| align="right" | 46 | 0.94825 | align="right" | 47 | 0.95477 |
----
| 0.99 | 3.03485{{sqrt|365}} = 57.98081 | align="right" | 57 | 0.99012 | align="right" | 58 | 0.99166 |
Some values falling outside the bounds have been colored to show that the approximation is not always exact.
Partition problem
A related problem is the partition problem, a variant of the knapsack problem from operations research. Some weights are put on a balance scale; each weight is an integer number of grams randomly chosen between one gram and one million grams (one tonne). The question is whether one can usually (that is, with probability close to 1) transfer the weights between the left and right arms to balance the scale. (In case the sum of all the weights is an odd number of grams, a discrepancy of one gram is allowed.) If there are only two or three weights, the answer is very clearly no; although there are some combinations which work, the majority of randomly selected combinations of three weights do not. If there are very many weights, the answer is clearly yes. The question is, how many are just sufficient? That is, what is the number of weights such that it is equally likely for it to be possible to balance them as it is to be impossible?
Often, people's intuition is that the answer is above {{val|100000}}. Most people's intuition is that it is in the thousands or tens of thousands, while others feel it should at least be in the hundreds. The correct answer is 23.{{Citation needed|date=December 2016}}
The reason is that the correct comparison is to the number of partitions of the weights into left and right. There are {{math|2N − 1}} different partitions for {{math|N}} weights, and the left sum minus the right sum can be thought of as a new random quantity for each partition. The distribution of the sum of weights is approximately Gaussian, with a peak at {{math|{{val|500000}}N}} and width {{math|{{val|1000000}}{{sqrt|N}}}}, so that when {{math|2N − 1}} is approximately equal to {{math|{{val|1000000}}{{sqrt|N}}}} the transition occurs. 223 − 1 is about 4 million, while the width of the distribution is only 5 million.{{cite journal |first1=C. |last1=Borgs |first2=J. |last2=Chayes |first3=B. |last3=Pittel |s2cid=6819493 |year=2001 |title=Phase Transition and Finite Size Scaling in the Integer Partition Problem |journal=Random Structures and Algorithms |volume=19 |issue=3–4 |pages=247–288 |doi=10.1002/rsa.10004 }}
In fiction
Arthur C. Clarke's 1961 novel A Fall of Moondust contains a section where the main characters, trapped underground for an indefinite amount of time, are celebrating a birthday and find themselves discussing the validity of the birthday problem. As stated by a physicist passenger: "If you have a group of more than twenty-four people, the odds are better than even that two of them have the same birthday." Eventually, out of 22 present, it is revealed that two characters share the same birthday, May 23.
Notes
{{reflist|group=nb}}
References
{{Reflist|45em}}
Bibliography
- {{cite journal |first1=M. |last1=Abramson |first2=W. O. J. |last2=Moser |year=1970 |title=More Birthday Surprises |journal=American Mathematical Monthly |volume=77 |issue= 8|pages=856–858 |doi= 10.2307/2317022|jstor=2317022 |ref=none}}
- {{cite journal |first=D. |last=Bloom |year=1973 |title=A Birthday Problem |journal=American Mathematical Monthly |volume=80 |issue= 10|pages=1141–1142 |doi=10.2307/2318556 | jstor=2318556 }}
- {{cite book |first1=John G. |last1=Kemeny |first2=J. Laurie |last2=Snell |first3=Gerald |last3=Thompson |title=Introduction to Finite Mathematics |edition=First |year=1957 |ref=none}}
- {{cite journal |first=E. H. |last=McKinney |year=1966 |title=Generalized Birthday Problem |journal=American Mathematical Monthly |volume=73 |issue= 5|pages=385–387 |doi= 10.2307/2315408|jstor=2315408|ref=none }}
- {{cite journal |first=F.|last=Mosteller |title=Understanding the Birthday Problem |year=1962 |journal=The Mathematics Teacher |volume=55 |issue= 5|pages=322–325|doi=10.5951/MT.55.5.0322 |jstor=27956609}} Reprinted in {{cite book|title=Selected Papers of Frederick Mosteller|chapter=Understanding the Birthday Problem |series=Springer Series in Statistics|isbn=978-0-387-20271-6 |doi= 10.1007/978-0-387-44956-2_21|pages=349–353|year=2006 |last1=Mosteller |first1=Frederick }}
- {{cite book |author1-link=Leila Schneps |first1=Leila |last1=Schneps |author2-link=Coralie Colmez |first2=Coralie |last2=Colmez |title=Math on Trial. How Numbers Get Used and Abused in the Courtroom |publisher=Basic Books |year=2013 |isbn=978-0-465-03292-1 |chapter=Math error number 5. The case of Diana Sylvester: cold hit analysis |ref=none|title-link=Math on Trial}}
- {{cite book|author=Sy M. Blinder|title=Guide to Essential Math: A Review for Physics, Chemistry and Engineering Students|url=https://books.google.com/books?id=M7TCNAEACAAJ|year=2013|publisher=Elsevier|isbn=978-0-12-407163-6|pages=5–6|ref=none}}
External links
- [http://www.efgh.com/math/birthday.htm The Birthday Paradox accounting for leap year birthdays]
- {{MathWorld | urlname=BirthdayProblem | title=Birthday Problem|ref=none}}
- [http://www.damninteresting.com/?p=402 A humorous article explaining the paradox]
- [http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_BirthdayExperiment SOCR EduMaterials activities birthday experiment]
- [http://betterexplained.com/articles/understanding-the-birthday-paradox/ Understanding the Birthday Problem (Better Explained)]
- [http://www.matifutbol.com/en/eurobirthdays.html Eurobirthdays 2012. A birthday problem.] A practical football example of the birthday paradox.
- {{cite web|last=Grime|first=James|title=23: Birthday Probability|url=http://www.numberphile.com/videos/23birthday.html|work=Numberphile|publisher=Brady Haran|access-date=2013-04-02|archive-url=https://web.archive.org/web/20170225140726/http://www.numberphile.com/videos/23birthday.html|archive-date=2017-02-25|url-status=dead|ref=none}}
- [https://www.wolframalpha.com/input/?i=birthday+paradox%2C+4+people%2C+100+possible+birthdays Computing the probabilities of the Birthday Problem at WolframAlpha]
{{Portal bar|Mathematics}}
{{DEFAULTSORT:Birthday Problem}}
Category:Probability theory paradoxes