<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Combinations on kenji.blog</title><link>http://kenji.blog/en/tags/combinations/</link><description>Recent content in Combinations on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>kenjinote</copyright><lastBuildDate>Thu, 10 Sep 2026 00:00:00 +0900</lastBuildDate><atom:link href="http://kenji.blog/en/tags/combinations/index.xml" rel="self" type="application/rss+xml"/><item><title>The Birthday Paradox: Over 50% with just 23 people? The magic of "combinations" that deceives intuition</title><link>http://kenji.blog/en/p/birthday-paradox/</link><pubDate>Thu, 10 Sep 2026 00:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/birthday-paradox/</guid><description>&lt;img src="http://kenji.blog/p/birthday-paradox/img/birthday_paradox.jpg" alt="Featured image of post The Birthday Paradox: Over 50% with just 23 people? The magic of "combinations" that deceives intuition" />&lt;h2 id="1-a-test-of-intuition-how-many-people-does-it-take-for-the-probability-to-exceed-50">1. A Test of Intuition: How many people does it take for the probability to exceed 50%?
&lt;/h2>&lt;p>People are gathering at a party venue.
Here, &lt;strong>how many people do you think are needed at a minimum for the probability of having at least one pair with the exact same birthday (month and day) to exceed 50%?&lt;/strong> (*Excluding leap years, assuming a year has 365 days, and each birthday is equally probable).&lt;/p>
&lt;p>Human intuition tends to calculate like this:
&amp;ldquo;There are 365 days in a year. If we pop people into 365 slots and expect an overlap, we&amp;rsquo;d probably need at least about 180 people. Even with a conservative estimate, shouldn&amp;rsquo;t there be 50 to 60 people for the probability to be half?&amp;rdquo;&lt;/p>
&lt;p>However, the correct answer derived by mathematics is a mere &lt;strong>&amp;ldquo;23 people&amp;rdquo;&lt;/strong>.
In a typical school class (about 30 to 40 people), the probability of a pair sharing a birthday jumps to about 70% to 89%. With 50 people, the probability reaches 97%, making it &amp;ldquo;more unusual not to have people with the same birthday.&amp;rdquo;&lt;/p>
&lt;p>Why does our intuition deviate so much from actual probability?&lt;/p>
&lt;hr>
&lt;h2 id="2-why-intuition-fails-the-difference-between-me-and-someone-and-someone-and-someone">2. Why Intuition Fails: The Difference Between &amp;ldquo;Me and Someone&amp;rdquo; and &amp;ldquo;Someone and Someone&amp;rdquo;
&lt;/h2>&lt;p>The biggest reason intuition fails in this problem is that we unconsciously think about the &lt;strong>&amp;ldquo;probability that someone has the same birthday as a specific person (e.g., yourself).&amp;rdquo;&lt;/strong>&lt;/p>
&lt;p>If you enter the venue and look for &amp;ldquo;someone with the same birthday as me,&amp;rdquo; the probability that someone among the 23 people shares your birthday is only &lt;strong>about 6.1%&lt;/strong>. (For this probability to exceed 50%, you would actually need 253 people).&lt;/p>
&lt;p>However, what the Birthday Paradox asks is not a pair of &amp;ldquo;me and someone.&amp;rdquo; It only requires one match among &lt;strong>&amp;ldquo;all possible combinations between everyone present at the venue (Person A and Person B, Person B and Person C, Person C and Person A&amp;hellip;).&amp;rdquo;&lt;/strong>&lt;/p>
&lt;div class="mermaid">graph TD
subgraph "Illusion of Intuition: 'Self'-centered comparison"
You["You"] --- P1["Person A"]
You --- P2["Person B"]
You --- P3["Person C"]
You --- P4["Person D"]
style You fill:#ff9999,stroke:#333,stroke-width:4px
end
subgraph "Reality: Round-robin comparison of 'Everyone with Everyone'"
A["Person A"] --- B["Person B"]
A --- C["Person C"]
A --- D["Person D"]
B --- C
B --- D
C --- D
end&lt;/div>
&lt;p>Even in a group of just 4 people, a comparison centered around &amp;ldquo;yourself&amp;rdquo; yields 3 pairs, but a comparison among everyone yields 6 pairs (${}_4 C_2 = 6$).
When the number of people increases to 23, the combinations of pairs explosively increase to a whopping &lt;strong>253 pairs&lt;/strong> (${}_{23} C_2$).
With as many as 253 pairs, doesn&amp;rsquo;t it start to feel unsurprising that at least one of those pairs might hit the &amp;ldquo;1 in 365&amp;rdquo; chance?&lt;/p>
&lt;hr>
&lt;h2 id="3-mathematical-proof-a-brilliant-solution-using-the-complementary-event">3. Mathematical Proof: A Brilliant Solution Using the Complementary Event
&lt;/h2>&lt;p>Calculating the &amp;ldquo;probability of at least one pair sharing a birthday&amp;rdquo; head-on is difficult (because there are too many patterns, such as exactly one pair matching, two pairs matching, three people having the same birthday&amp;hellip;).
Therefore, we use a fundamental technique in probability theory: the &lt;strong>&amp;ldquo;complementary event.&amp;rdquo;&lt;/strong>&lt;/p>
&lt;p>A complementary event refers to the &amp;ldquo;probability of something not happening.&amp;rdquo;
In other words, we calculate the &lt;strong>&amp;ldquo;probability that everyone&amp;rsquo;s birthday is different (not a single pair overlaps),&amp;rdquo;&lt;/strong> and subtract it from 100% (1) to get the probability we want.&lt;/p>
$$ P(\text{At least 2 people share a birthday}) = 1 - P(\text{Everyone has a different birthday}) $$
&lt;p>Now, let&amp;rsquo;s imagine people entering the venue one by one and calculate.&lt;/p>
&lt;ol>
&lt;li>&lt;strong>1st person&lt;/strong>: There&amp;rsquo;s no worry of overlapping with anyone. The probability is $\frac{365}{365}$.&lt;/li>
&lt;li>&lt;strong>2nd person&lt;/strong>: Must have a different birthday from the 1st person. The remaining 364 days are safe. The probability is $\frac{364}{365}$.&lt;/li>
&lt;li>&lt;strong>3rd person&lt;/strong>: Must have a different birthday from the previous 2 people. The remaining 363 days are safe. The probability is $\frac{363}{365}$.&lt;/li>
&lt;/ol>
&lt;p>Multiplying this up to the $n$-th person gives the general formula for the probability $P(n)'$ that everyone has a different birthday.&lt;/p>
$$ P(n)' = \frac{365}{365} \times \frac{364}{365} \times \frac{363}{365} \times \dots \times \frac{365 - (n - 1)}{365} $$
$$ P(n)' = \prod_{k=1}^{n-1} \left(1 - \frac{k}{365}\right) $$
&lt;p>Therefore, the sought &amp;ldquo;probability $P(n)$ that at least 2 people share a birthday&amp;rdquo; is as follows:&lt;/p>
$$ P(n) = 1 - \prod_{k=1}^{n-1} \left(1 - \frac{k}{365}\right) $$
&lt;p>If we substitute the number of people $n$ into this formula, we can see the probability rises at an astonishing speed.&lt;/p>
&lt;ul>
&lt;li>When $n = 10$, the probability is about &lt;strong>11.7%&lt;/strong>&lt;/li>
&lt;li>When $n = 23$, the probability is about &lt;strong>50.7%&lt;/strong> (it crosses 50% here!)&lt;/li>
&lt;li>When $n = 40$, the probability is about &lt;strong>89.1%&lt;/strong>&lt;/li>
&lt;li>When $n = 70$, the probability is about &lt;strong>99.9%&lt;/strong>&lt;/li>
&lt;/ul>
&lt;div class="mermaid">pie title "Probability when 23 people gather"
"There is a pair with the same birthday (50.7%)" : 50.7
"Everyone is different (49.3%)" : 49.3&lt;/div>
&lt;hr>
&lt;h2 id="4-approximate-calculation-via-taylor-expansion">4. Approximate Calculation via Taylor Expansion
&lt;/h2>&lt;p>Calculating 23 multiplications by hand is tedious, so let&amp;rsquo;s use a mathematical approximation formula to understand it a bit more intuitively.&lt;/p>
&lt;p>Consider the Taylor expansion of the exponential function $e^{-x}$. When $x$ is sufficiently small, the following approximation holds:
&lt;/p>
$$ e^{-x} \approx 1 - x $$
&lt;p>Applying this to each term $\left(1 - \frac{k}{365}\right)$ from earlier:
&lt;/p>
$$ 1 - \frac{k}{365} \approx e^{-\frac{k}{365}} $$
&lt;p>Multiplying all of these together (which becomes addition by the laws of exponents):
&lt;/p>
$$ P(n)' \approx e^{-\frac{1}{365}} \times e^{-\frac{2}{365}} \times \dots \times e^{-\frac{n-1}{365}} $$
$$ P(n)' \approx \exp\left(-\sum_{k=1}^{n-1} \frac{k}{365}\right) $$
&lt;p>The sum from 1 to $n-1$ is $\frac{n(n-1)}{2}$ (that is, the number of combinations ${}_n C_2$), so:
&lt;/p>
$$ P(n)' \approx \exp\left(-\frac{n(n-1)}{2 \times 365}\right) $$
&lt;p>Using this formula, we find $n$ when the probability is 50% ($0.5$).
&lt;/p>
$$ 0.5 = e^{-\frac{n(n-1)}{730}} $$
&lt;p>
Taking the natural logarithm of both sides ($\ln 0.5 \approx -0.693$):
&lt;/p>
$$ -0.693 = -\frac{n(n-1)}{730} $$
$$ n(n-1) = 0.693 \times 730 \approx 505.89 $$
&lt;p>Approximating as $n^2 \approx 506$, we get $n = \sqrt{506} \approx 22.49$
The answer &lt;strong>$n \approx 23$&lt;/strong> is beautifully derived!&lt;/p>
&lt;hr>
&lt;h2 id="5-application-to-daily-life-and-hash-collisions">5. Application to Daily Life and &amp;ldquo;Hash Collisions&amp;rdquo;
&lt;/h2>&lt;p>This paradox is not just a party trick. It plays a critically important role in the &lt;strong>cryptography and information security&lt;/strong> that supports modern IT society.&lt;/p>
&lt;p>Computer systems use a mechanism called a &amp;ldquo;hash function&amp;rdquo; to quickly verify the identity of passwords or files. A hash function returns a random string of a fixed length (a hash value) no matter what data is put in.
However, the phenomenon where these hash values coincidentally turn out to be the same is called a &lt;strong>&amp;ldquo;Hash Collision.&amp;rdquo;&lt;/strong>&lt;/p>
&lt;p>Hash collisions occur due to the exact same principle as the Birthday Paradox.
Contrary to human intuition, which assumes &amp;ldquo;since the number of possible hash values is astronomical, collisions would rarely happen,&amp;rdquo; it is surprisingly easy for an attacker to randomly generate a massive amount of data and find a &amp;ldquo;pair that matches (has the same birthday).&amp;rdquo;&lt;/p>
&lt;p>This is called a &lt;strong>&amp;ldquo;Birthday Attack.&amp;rdquo;&lt;/strong>
Engineers designing security systems assume this mathematical fact that &amp;ldquo;collisions happen far faster than intuition suggests,&amp;rdquo; and ensure safety by setting the hash length to be extremely long.&lt;/p>
&lt;h2 id="6-conclusion-the-limits-of-human-intuition">6. Conclusion: The Limits of Human Intuition
&lt;/h2>&lt;p>The Birthday Paradox is a perfect example of &lt;strong>how fragile human intuition is against &amp;ldquo;exponential growth&amp;rdquo; and &amp;ldquo;combinatorial explosions.&amp;rdquo;&lt;/strong>&lt;/p>
&lt;p>We are strong at linear (additive) growth, but we cannot simulate in our brains a phenomenon where the number of pairs explodes at a pace of $n^2$.
Behind the intuition that &amp;ldquo;the number 23 is too small compared to the large number 365,&amp;rdquo; there are &lt;strong>&amp;ldquo;253 invisible threads (pairs)&amp;rdquo;&lt;/strong> woven by 23 people.&lt;/p>
&lt;p>Next time you go to a place where people gather, try to imagine not just the visible &amp;ldquo;number of people,&amp;rdquo; but the &amp;ldquo;threads of combinations&amp;rdquo; that exist innumerably among them. The way you view the world should change just a little bit mathematically.&lt;/p></description></item></channel></rss>