In probability theory, the birthday problem asks for the probability that, in a set of 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 (the number being less than 1/15th of the number of days in a year), 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 23×222=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". The first publication of a version of the birthday problem was by Richard von Mises in 1939.
Calculating the probability
Consider the event A that a group of k people does not have any repeated birthdays, and let the complementary event B be that of a group of k people contains at least two people who share a birthday. Then the probabilities P(A) and P(B) of the two events are related by the equation P(B) = 1 − P(A). The probability P(A) can be computed using the perspective of permutations, as follows. Let V𝑛𝑟 be the total number of ways that k people can have distinct birthdays, and let Vt be the total number of ways k people can have birthdays arranged, including possibly repeated birthdays. The probability P(A) is the ratio of these two quantities, V𝑛𝑟 divided by Vt. When k=23, the two counts are given by V𝑛𝑟=365⋅364⋅363⋅⋯⋅(365−22)=365!(365−23)! and Vt=365⋅365⋅365⋅⋯⋅365=36523, their ratio is P(A)=V𝑛𝑟Vt≈0.492703, and so P(B)=1−P(A)≈1−0.492703=0.507297(50.7297%). Another way the birthday problem can be solved is by asking for an approximate probability that in a group of n people at least two have the same birthday. For simplicity, leap years, twins, selection bias, and seasonal and weekly variations in birth rates 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. 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. The goal is to compute P(B), the probability that at least two people in the room have the same birthday. However, it is simpler to calculate P(A′), the probability that no two people in the room have the same birthday. Then, because B and A′ are the only two possibilities and are also mutually exclusive, P(B) = 1 − P(A′). Here is the calculation of P(A) 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 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 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 343/365. Finally, the principle of conditional probability implies that P(A′) is equal to the product of these individual probabilities:
The terms of equation (1) can be collected to arrive at:
Evaluating equation (2) gives P(A′) ≈ 0.492703 Therefore, P(B) ≈ 1 − 0.492703 = 0.507297 (50.7297%). This process can be generalized to a group of n people, where p(n) is the probability of at least two of the n people sharing a birthday. It is easier to first calculate the probability p(n) that all n birthdays are different. According to the pigeonhole principle, p(n) is zero when n > 365. When n ≤ 365:
p¯(n)=1×(1−1365)×(1−2365)×⋯×(1−n−1365)=365×364×⋯×(365−n+1)365n=365!365n(365−n)!=n!⋅(365n)365n=365Pn365n where ! is the factorial operator, (365n) is the binomial coefficient and 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 (364/365), the third cannot have the same birthday as either of the first two (363/365), and in general the nth birthday cannot be the same as any of the n − 1 preceding birthdays. The event of at least two of the n persons having the same birthday is complementary to all n birthdays being different. Therefore, its probability p(n) is
p(n)=1−p¯(n). The following table shows the probability for some other values of n (for this table, the existence of leap years is ignored, and each birthday is assumed to be equally likely):
Approximations
The Taylor series expansion of the exponential function (the constant e ≈ 2.718281828)
ex=1+x+x22!+⋯ provides a first-order approximation for ex for |x|≪1:
ex≈1+x. To apply this approximation to the first expression derived for p(n), set x = −a/365. Thus,
e−a/365≈1−a365. Then, replace a with non-negative integers for each term in the formula of p(n) until a = n − 1, for example, when a = 1,
… excerpt ends here. Continue reading the full article.





