ArticleslgStudy

mathematics

Birthday problem

Birthday problem is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Birthday problem rather than just read about it. In short: 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%.

Birthday problem — main illustration
Birthday problem — illustration

Key takeaways

  • Birthday problem belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Birthday problem to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Birthday problem from memory before moving on to harder problems.

Reference excerpt

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.

Illustrations

Birthday problem: The computed probability of at least two people sharing the same birthday versus the number of people
The computed probability of at least two people sharing the same birthday versus the number of people
Birthday problem: The probability that no two people share a birthday in a group of n people. Note that the vertical scale is logarithmic (each step down is 1020 times less likely).
The probability that no two people share a birthday in a group of n people. Note that the vertical scale is logarithmic (each step down is 1020 times less likely).
Birthday problem: Graphs showing the approximate probabilities of at least two people sharing a birthday (@media screen{html.skin-theme-clientpref-night .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}red) and its complementary event (blue)
Graphs showing the approximate probabilities of at least two people sharing a birthday (@media screen{html.skin-theme-clientpref-night .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}red) and its complementary event (blue)
Birthday problem: A graph showing the accuracy of the approximation 1 − e−n2/730 (red)
A graph showing the accuracy of the approximation 1 − e−n2/730 (red)
Birthday problem: Comparison of the birthday problem (1) and birthday attack (2):
In (1), collisions are found within one set, in this case, 3 out of 276 pairings of the 24 lunar astronauts.
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.
Comparison of the birthday problem (1) and birthday attack (2): In (1), collisions are found within one set, in this case, 3 out of 276 pairings of the 24 lunar astronauts. 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.

Worked examples

Example 1 — a first encounter with Birthday problem

Start with the simplest possible case. Write down what Birthday problem claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Birthday problem before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Birthday problem ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Birthday problem

In research
Birthday problem appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Birthday problem in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Birthday problem is common in secondary-school and first-year university syllabi. It links to neighbouring topics Applied probability, Birthdays, Coincidence, so understanding it makes those chapters shorter.
In everyday life
Look for Birthday problem outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Birthday problem” →

How to study Birthday problem in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Birthday problem means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Birthday problem out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Birthday problem in simple terms?

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%.

Why does Birthday problem matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Birthday problem?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Birthday problem.

Tags

  • Applied probability
  • Birthdays
  • Coincidence
  • Mathematical problems
  • Probability problems
  • Probability theory paradoxes

Keep exploring