Professional Documents
Culture Documents
23 people. In a room of just 23 people theres a 50-50 chance of two people having the same birthday. In a room of 75
theres a 99.9% chance of two people matching.
Put down the calculator and pitchfork, I dont speak heresy. The birthday paradox is strange, counter-intuitive, and
completely true. Its only a paradox because our brains cant handle the compounding power of exponents. We expect
probabilities to be linear and only consider the scenarios were involved in (both faulty assumptions, by the way).
Lets see why the paradox happens and how it works.
Makes sense, right? Theres 364 out of 365 birthdays that are OK.
Having all 253 pairs be different is like getting heads 253 times in a row (well, sort-of: lets assume birthdays are
independent). We use exponents to nd the probability:
99.7260% is really close to one, but when you multiply it by itself a few hundred times, it shrinks. Really fast.
The chance that we have a match is: 1 49.95% = 50.05%, or just over half! If you want to nd the probability of a match for
The chance that we have a match is: 1 49.95% = 50.05%, or just over half! If you want to nd the probability of a match for
any number of people n the formula is:
Interactive Example
I didnt believe we needed only 23 people. The math works out, but is it real?
You bet. Try the example below: Pick a number of items (365), a number of people (23) and run a few trials. Youll see the
theoretical match and your actual match as you run your trials. Go ahead, click the button (or see the full page
(http://betterexplained.com/examples/birthday/birthday.html)).
Tryoutthebirthdayparadox
Items: 365
People: 23
RunTrial reset
frombetterexplained.com
As you run more and more trials (keep clicking!) the actual probability should approach the theoretical one.
But theres a shortcut we can take. When x is close to 0, a coarse rst-order Taylor approximation for ex is:
so
Using our handy shortcut we can rewrite the big equation to:
But we remember that adding the numbers 1 to n (http://betterexplained.com/articles/techniques-for-adding-the-numbers1-to-100/) = n(n + 1)/2. Dont confuse this with n(n-1)/2, which is C(n,2) or the number of pairs of n items. They look almost
the same!
Adding 1 to 22 is (22 * 23)/2 so we get:
and
Voila! If you take sqrt(T) items (17% more if you want to be picky) then you have about a 50-50 chance of getting a match. If
you plug in other numbers (http://tinyurl.com/2rhwwu) you can solve for other probabilities:
Remember that m is the desired chance of a match (its easy to get confused, I did it myself). If you want a 90% chance of
matching birthdays, plug m=90% and T=365 into the equation and see that you need 41 people (http://tinyurl.com/yw6fmx).
Wikipedia has even more details (http://en.wikipedia.org/wiki/Birthday_paradox) to satisfy your inner nerd. Go forth and
enjoy.
BirthdayFormula
R1 people=23
23
R2 days=365
365
R3 pairs=(people*(people1))/2
253
R4 chanceperpair=pairs/days 0.69315068493
R5 chancedifferent
50.00
R6 chanceofmatch
50.00
+5rowsClear
Hi! I'm Kalid, author, programmer, and ever-curious learner. I want to give you a lasting, intuitive understanding of math. Join
the newsletter and we'll turn Huh? to Aha!
Email address
ContributeanInsight
AskaQuestion
ContributeanInsight
Ask Question
Name (optional)
Have feedback? Just enter it above. I'm making a curated set of questions and insights for the article. Thanks!
190 comments
1. Herman Hiddema says:
The math here is actually wrong. The chances of individual pairs are not independent. You math would work if you take
each pair and have them name a random number between 1 and 365.
With this math, taking a group of 365 people still results in a non-zero chance that they all have different birthdays.
2. Kalid says:
Thanks for the info, youre right. I did some more digging (good paper here (http://ocw.mit.edu/NR/rdonlyres/ElectricalEngineering-and-Computer-Science/6-042JMathematics-for-Computer-ScienceFall2002/033D4EB6-FA3E-44B5-9103921AEEF10AC2/0/ln10.pdf)) and birthdays arent mutually independent.
If Person 1 = Person 3, and Person 3 = Person 5, there isnt an independent event that Person 1 = Person 5. The probability
of 1 matching 5 has already been determined by the other statements.
From what I was able to gather, this is only a problem if there are existing overlapping pairs. For a small n relative to the
number of outcomes (365), its unlikely to have multiple matches that affect the probability, so assuming independence
may be ok for computing approximations.
3. Anonymous says:
The last formula is incorrect, it should be:
n ~ sqt(-2 ln(1-p)) sqt(T)
^^^
or else you are nding the probability to miss.
4. Kalid says:
Thanks for the tip! I xed up the article to use p(different) and p(match), which is much more clear.
5. Pseudonym says:
The take-away lesson about GUIDs is wrong. GUIDs are (theoretically) guaranteed to be globally unique, because they
include such things as the MAC address of your network card (something which is globally unique until some cheap NIC
manufacturer starts recycling them) and the current time.
The catch is that because of the time factor, the current GUID algorithm wont last forever. We will run out in a couple of
centuries.
7. Allan says:
can the math in the birthday paradox applicable to pick3 lottery?
In Pick3, you dont really care if two guesses collide you want the guess to collide with the winning number. In this
case, two losing tickets that both guessed 123 (when the real answer was 999) isnt helpful.
I may be missing something though!
This approximation makes the math easier, and is ok for small values. If you want the actual %, take a look at Appendix
A.
Yep, the paradox seems strange, doesnt it? Take a look at this page and run some experiments on your own to see:
http://betterexplained.com/examples/birthday/birthday.html
(http://betterexplained.com/examples/birthday/birthday.html)
As you click run trial, you will see the actual match percentage for 23 people approach 50%, which is the predicted one.
Hope this helps.
The explanations given are all approximations, in order to get an exact result you follow the start to Appendix A, but
dont attempt to simplify with e^x. The solution is actually fairly simple, for n possibilities (days in the year) and k events
(people at the party) we get a probability of:
1 (P(n-1,k-1)/(n^(k-1))).
Where P(n,k) is the number of ways to pick k elements from a set of n, or n!/(n-k)!.
This will give an exact solution, the probability of nding two people with the same birthday from a crowd of 23 is more
accurately: 50.7297234%
I hope that this makes sense, if it doesnt, look at the page on combinatorics and/or think about the fact that (1-(j/n)) =
((n-j)/n) with reference to Appendix A.
imagine throwing 23 point blobs of paint at a calender on the wall. Then move all the dates that hit into a tidy ~55
square in the corner.
Now throw another 23 blobs of paint at the wall.
To me, it is almost inconceivable that no paint blobs will now touch the dates in the 23 blob square in the corner (50/50
maybe)
-d
It can help to remember that if there were 367 people in the room, then the chances we have a hit are not just very high,
but are actually 100%. EVERY room with 367 or more people has two or more people sharing a birthday. Thats because
the only other possibility is that there are 367 unique birthdays in that room, and there arent that many birthdays to go
around.
What if there were 366 people? Then its possible they each have their own birthday (including a Leap Day birthday!), but
thats EXTREMELY unlikely. So the chances of a match are very close to 100%.
What if there were 365 people? Just a bit less. 364 people? Slightly less than that.
and so on, down to 23. At 23 people, the chances are just over 50%. At 22, they are below 50%. At 2, they are about
1/365, or well below 1%.
The whole thing is just a graph that curves differently than you might expect.
Getting 10 heads in a row is actually .5^9 Because the .5 is accounting after you ipped a coin once.
112. me says:
@spope I think it probably rounds.. so it would be 99.999102% (or something like that) so it rounds to 100%.. just a
guess..
113. Bo says:
The formula cant be exact. Using this formula, you would calculate a (though small) chance that in a room of 366 people
there would be not a single mutual birthday. This cant be correct as there are in this case more people than days in a
year. Therefore the possibility to have not a single same birthday should be as zero as it could ever be.
chances of someone NOT having the same birthday as another person. -1 to view -0.5005which is only a quick way of
seeing the answer when the real equation is 1 0.4995 to give you your answer being 0.5005 (50.05% likely of someone
having the same birthday as another.
Instead, you work out the dice probabilities by asking the opposite question: What is the probability of rolling anything
but a one? With two dice, there are ve-times- ve equally-likely ways to do this (as if the dice only had 5 sides): a two
and a two, a two and a three, etc, all the way to a six and a six. And here are 36 total equally-likely possible combinations:
one-one, one-two, and so on. So our answer to this question is 25/36. That means the answer to our original question is
just 1-25/36, or 11/36.
Getting back to the birthdays, the way to determine the probability with 23 people is not to add the independent
probabilities, because then you get a false guarantee of a pair at 28 people (there are 378 pairs, so you would nd a
probability of 378/365 for a pair, and that number cant even be right in itself probabilities should never exceed 1).
Instead, we do multiplication, and what we multiply is the inverse scenario: 364/365, or the probability that two people
dont share a birthday.
We multiply this number by itself 253 times (in other words, raise it to the 253rd power). The result is a number slightly
less than 1/2: 0.4995. This means that the probability for the reverse question is slightly more than 1/2, about 0.5005.
However, this is slightly off because of the non-independence factor. The more correct way to calculate it is to build the
sets of possible rooms that lack matches, and this isnt as hard as you might think. (Its simpler to understand than the
methods shown in the blog post.)
The rst person who enters the room is permitted to have any of 365 birthdays. The second person we put into it is only
allowed one of 364 birthdays, because they cant be a match. The third person is allowed one of 363 birthdays, because
she cant match either of the rst two. All these possibilites multiply out, for the twenty-three people: 365 x 364 x 363x
362 x 361 x 345 x 344 x 343.
Thats our numerator: The total set of equally-likely combinations that ful ll a principle of lacking any matched pairs.
For our denominator, we need the total set of possible combinations in general, and that would be 365 x 365 x 365 x 365
twenty-three times.
The resultant number is about 0.4927 which, as before, is just under one-half. Hence, although we have a more precise
probability, we still nd that the same number of people (23) is the threshold here.
You start counting digits from left to right starting with the rst non-zero digit.
0.123 0.0123 0.00123 0.102 0.350 0.300
Solution or Explanation
This is tricky because it doesnt matter how large the class is. Also, it doesnt matter what the rst persons birthday is.
The probability that the second person has the same birthday is
1
365
= 0.0027397 0.00274
to three signi cant digits.
Comment
LaTeX: $$e=mc^2$$
Post Comment
In This Series
1. A Brief Introduction to Probability & Statistics (http://betterexplained.com/articles/a-brief-introduction-to-probability-statistics/)
2. How To Analyze Data Using the Average (http://betterexplained.com/articles/how-to-analyze-data-using-the-average/)
3. An Intuitive (and Short) Explanation of Bayes' Theorem (http://betterexplained.com/articles/an-intuitive-and-short-explanation-ofbayes-theorem/)
4. Understanding Bayes Theorem With Ratios (http://betterexplained.com/articles/understanding-bayes-theorem-with-ratios/)
5. Understanding the Birthday Paradox (http://betterexplained.com/articles/understanding-the-birthday-paradox/)
6. Understanding the Monty Hall Problem (http://betterexplained.com/articles/understanding-the-monty-hall-problem/)
Calculus Course
(/calculus).
If you can't explain it simply, you don't understand it well enough. Einstein (more (/philosophy/))
About (/about/)
Privacy (/privacy/)
Contact (/contact/)