# 生日问题

生日问题问的是：一群人要有多大，才能使得其中至少两人同一天生日的可能性超过一半？在365天等可能且相互独立的标准假设下，答案是23人：至少有一对同一天生日的概率为0.507，略高于二分之一。<sup>[1](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/12%3A_Finite_Sampling_Models/12.06%3A_The_Birthday_Problem)</sup> 这个结果常被称为生日悖论，因为23这个数字在多数人看来太小了，尽管整个计算并不涉及任何逻辑矛盾。<sup>[2](https://data140.org/textbook/content/chapter-01/birthday-problem/)</sup>

| 关键事实 | 详情 |
|---|---|
| 临界人数 | 假设365天等可能，23人时至少一对同生日的概率为0.507<sup>[1](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/12%3A_Finite_Sampling_Models/12.06%3A_The_Birthday_Problem)</sup> |
| 精确公式 | 对 \( N \) 个可能日期和 \( n \) 个人，\( P(\text{匹配}) = 1 - \prod_{i=0}^{n-1} \frac{N-i}{N} \)<sup>[2](https://data140.org/textbook/content/chapter-01/birthday-problem/)</sup> |
| 近似 | 50%临界值约为 \( m \approx \sqrt{2N \ln 2} \)，当 \( N = 365 \) 时给出22.49<sup>[3](https://www.cs.purdue.edu/homes/spa/courses/pg17/mu-book.pdf)</sup> |
| 起源 | 理查德·冯·米泽斯于1939年首次发表该问题<sup>[4](https://larrylesser.com/birthday/)</sup> |
| 真实出生分布的影响 | 任何偏离均匀出生日期分布的情况都会增加匹配的概率，因此23人仍然足够<sup>[5](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x)</sup> |
| 密码学形式 | 在理想的 \( n \) 比特哈希函数中，找到一个碰撞大约需要 \( 2^{n/2} \) 次运算<sup>[6](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934860)</sup> |
| 三重生日 | 至少需要88人，才能使三人同生日的概率达到五成<sup>[5](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x)</sup> |

## 计算

从反面入手最容易解决这个问题。第一个人生日可以是任意一天。第二个人避开第一个人生日的概率是 \( 1 - 1/365 \)，第三个人避开前两个人生日的概率是 \( 1 - 2/365 \)，依此类推。因此，\( n \) 个人生日全不相同的概率就是下降乘积

\[ P(\text{无匹配}) = \prod_{i=0}^{n-1} \frac{N-i}{N}, \]

而至少有一对同生日的概率就是一减去这个量。<sup>[2](https://data140.org/textbook/content/chapter-01/birthday-problem/)</sup> 当 \( n > N \) 时概率为1，这是鸽巢原理的一个例子：超过 \( N \) 个人不可能在 \( N \) 天里全都生日不同。<sup>[1](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/12%3A_Finite_Sampling_Models/12.06%3A_The_Birthday_Problem)</sup>

临界值之所以这么小，是因为配对数量随群体规模呈二次增长。\( n \) 个人共有 \( n(n-1)/2 \) 对，每对匹配的概率为 \( 1/N \)，因此一旦 \( n \) 超过大约 \( \sqrt{N} \)，碰撞就变得很可能。<sup>[6](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934860)</sup> 利用近似 \( 1 - k/N \approx e^{-k/N} \)，无匹配概率大约变为 \( e^{-n(n-1)/(2N)} \)，令其等于 \( 1/2 \)，即得临界值

\[ m \approx \sqrt{2N \ln 2} \approx 1.177 \sqrt{N}. \]

当 \( N = 365 \) 时得到 \( m = 22.49 \)，与精确计算高度吻合。<sup>[3](https://www.cs.purdue.edu/homes/spa/courses/pg17/mu-book.pdf)</sup>

## 概率上升有多快

一旦群体越过临界值，概率便急剧攀升。对 \( N = 365 \)，至少一对同生日的概率在10人时为0.117，20人时为0.411，30人时为0.706，40人时为0.891，50人时为0.970，60人时为0.994。<sup>[1](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/12%3A_Finite_Sampling_Models/12.06%3A_The_Birthday_Problem)</sup> 超过约50人后，匹配几乎已成定局。<sup>[2](https://data140.org/textbook/content/chapter-01/birthday-problem/)</sup>

同样的平方根尺度支配着相关问题。等到有人以第 \( k \) 个不同生日出现所需的人数，以及第一次碰撞出现前预期抽取的人数——约为 \( \sqrt{N\pi/2} \)——都出自同一个碰撞过程。<sup>[7](https://arxiv.org/abs/1310.7055)</sup> 相比之下，“需要多少人才能有人与你同一天生日”这个问题呈线性而非二次增长：约为 \( N \ln 2 \)，当 \( N = 365 \) 时为253人。<sup>[8](https://www.physics.harvard.edu/resource/solution46)</sup>

## 真实的生日并不均匀

经典解法假设一年中每天都等可能，并忽略了闰年、双胞胎和季节模式。<sup>[2](https://data140.org/textbook/content/chapter-01/birthday-problem/)</sup> 真实的出生分布并非如此。美国出生人数呈季节性模式，在比日均频率 \( 1/365 \) 低5%至高7%的范围内波动。<sup>[9](https://www.tandfonline.com/doi/full/10.1080/00031305.1992.10475901)</sup> 在英格兰和威尔士，每日出生数随星期几变化，周二至周五高于平均值，周末最低，而1979年至2014年间最受欢迎的生日是9月25日。<sup>[5](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x)</sup><sup> • </sup><sup>[10](https://academic.oup.com/jrssig/article/14/1/6/7030072)</sup>

**非均匀性有利于而非妨碍匹配。** 任何偏离均匀性的情况都会增加群体中存在一对同生日者的机会，因此既然23人对366个等可能日期已经足够，当某些日期比其他日期更可能出现时，23人当然也足够。<sup>[5](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x)</sup> 这种效应的影响很小。将每日频率写作 \( p_j = 1/N + d_j \)，其中 \( \sum d_j = 0 \)，对1979年至2005年英格兰和威尔士的合并数据，变异度量 \( S = \sum d_j^2 \) 为 \( 3.59 \times 10^{-6} \)；这把无匹配概率 \( D(365, 22) = 0.523 \) 乘以0.99917，结果仍稳稳高于50%。<sup>[5](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x)</sup> 努尼霍芬对非均匀美国出生率的递归处理同样发现，与经典解法的差异很小。<sup>[9](https://www.tandfonline.com/doi/full/10.1080/00031305.1992.10475901)</sup>

## 变体

**三重生日。** 要问一群人要多大，才能使至少三人同生日的可能性超过一半，需要更谨慎的处理。基于 \( r(r-1)(r-2) = 6N \ln 2 \) 的泊松近似建议当 \( N = 365 \) 时 \( r = 82 \)，但精确计算表明至少需要88人。这一差距源于三重生日的指示变量甚至不是两两独立的，因此计数相对于泊松分布是过度离散的；当 \( r = 82 \) 时，其方差约为均值的1.65倍。<sup>[5](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x)</sup>

**覆盖全年。** 强生日问题把问题反过来问：需要多少人，才能使一年中每一天都是某人的生日？在均匀假设下答案约为3064人，而真实生日的非均匀分布对这个数字影响极小。<sup>[11](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2013.00705.x)</sup>

**推广。** 该问题可推广到任意样本量和总体、不等概率，以及聚会中的夫妻等场景；大量文献综述了经典问题、其泊松渐近性以及不等概率的情形。<sup>[12](https://doi.org/10.1016/j.jspi.2003.11.015)</sup> 碰撞论证的变体也出现在马尔可夫链中，例如在阶为 \( |G| \) 的群中，用于离散对数的波拉德ρ算法中的碰撞在 \( \Theta(\sqrt{|G|}) \) 步内发生。<sup>[13](https://arxiv.org/abs/0712.0220)</sup>

## 密码学中的生日攻击

生日问题是密码学哈希函数上生日攻击的基础。哈希函数把任意长度的输入映射为 \( n \) 比特的摘要，碰撞就是两个不同输入具有相同摘要。把 \( 2^n \) 个可能摘要视为格子、每次哈希求值视为一个球，生日数学表明大约 \( 2^{n/2} \) 次求值就足以以合理的概率找到碰撞。在理想的 \( n \) 比特哈希算法中，寻找碰撞应需要 \( 2^{n/2} \) 次运算；弱点就是任何理论上能以更少运算找到碰撞的攻击，而一旦实际碰撞被公开发表，该哈希函数就被视为已被攻破。<sup>[6](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934860)</sup> 更一般地，当 \( n \) 个输入不可预测地映射到 \( k \) 个可能输出时，共有 \( n(n-1)/2 \) 对，每对匹配概率为 \( 1/k \)，因此大约需要 \( k/2 \) 对才能有五成匹配机会；若 \( n \) 超过 \( \sqrt{k} \)，则很可能存在一对匹配。<sup>[6](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934860)</sup>

这个 \( n/2 \) 比特的限制有时被称为生日屏障。宽管和快速宽管等哈希模式通过扩大内部状态来把安全性推到此限制之外；在美国国家标准与技术研究院和滑铁卢大学的达斯汀·穆迪、苏拉迪尤蒂·保罗和丹尼尔·史密斯-通的工作中，快速宽管模式已证明的不可区分性界从 \( n/2 \) 比特提高到了 \( 2n/3 \) 比特。<sup>[14](https://csrc.nist.gov/pubs/journal/2016/04/indifferentiability-security-of-the-fast-widepipe/final)</sup> 抗碰撞性对数字签名也至关重要，美国国家标准与技术研究院批准的签名算法在签名生成和验证中要求使用经批准的哈希函数。<sup>[15](https://www.nist.gov/publications/randomized-hashing-digital-signatures)</sup>

## 历史

奥地利数学家、概率论学者理查德·冯·米泽斯（Richard von Mises）于1939年首次发表了生日问题。<sup>[4](https://larrylesser.com/birthday/)</sup> 加州大学伯克利分校的Data 140教材指出，该问题由冯·米泽斯和其他数学家提出，其确切起源尚未得到充分确认。<sup>[2](https://data140.org/textbook/content/chapter-01/birthday-problem/)</sup> 达文波特（Davenport）提出的一个相关版本发表于1939年第十一版鲍尔与考克斯特的《数学游戏与随笔》（*Mathematical Recreations and Essays*），问的是最小的群体规模，使得一个男孩和一个女孩同生日的可能性超过一半；16个男孩和16个女孩即可。<sup>[16](https://pballew.blogspot.com/2011/01/who-created-birthday-problem-and-even.html)</sup>

## References

1. [12.6: The Birthday Problem, Statistics LibreTexts (Siegrist)](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_%28Siegrist%29/12%3A_Finite_Sampling_Models/12.06%3A_The_Birthday_Problem)
2. [1.4 The Birthday Problem, Data 140 Textbook, UC Berkeley](https://data140.org/textbook/content/chapter-01/birthday-problem/)
3. [Mitzenmacher & Upfal, Probability and Computing, section 5.1](https://www.cs.purdue.edu/homes/spa/courses/pg17/mu-book.pdf)
4. [Larry Lesser, birthday problem history page](https://larrylesser.com/birthday/)
5. [M. Cortina Borja, The birthday problem, Significance (2007)](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x)
6. [Kaufman, Perlman & Speciner, Network Security: Private Communication in a Public World, 3rd ed., chapter 5](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934860)
7. [Asymptotic distribution for the birthday problem with multiple coincidences, arXiv](https://arxiv.org/abs/1310.7055)
8. [Harvard Physics solution 46: shared birthday with a specific person](https://www.physics.harvard.edu/resource/solution46)
9. [T. S. Nunnikhoven, A Birthday Problem Solution for Nonuniform Birth Frequencies, The American Statistician 46(4), 1992](https://www.tandfonline.com/doi/full/10.1080/00031305.1992.10475901)
10. [What is the most popular birthday in England and Wales?, Significance (2017)](https://academic.oup.com/jrssig/article/14/1/6/7030072)
11. [M. Cortina Borja, The strong birthday problem, Significance (2013)](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2013.00705.x)
12. [A. DasGupta, The matching, birthday and the strong birthday problem: a contemporary review, Journal of Statistical Planning and Inference (2005)](https://doi.org/10.1016/j.jspi.2003.11.015)
13. [A Birthday Paradox for Markov chains, with an optimal bound for collision in Pollard's Rho algorithm, arXiv](https://arxiv.org/abs/0712.0220)
14. [Indifferentiability Security of the Fast Widepipe Hash: Breaking the Birthday Barrier, NIST CSRC (2016)](https://csrc.nist.gov/pubs/journal/2016/04/indifferentiability-security-of-the-fast-widepipe/final)
15. [Randomized Hashing for Digital Signatures, NIST](https://www.nist.gov/publications/randomized-hashing-digital-signatures)
16. [Pat'sBlog: Who created the birthday problem](https://pballew.blogspot.com/2011/01/who-created-birthday-problem-and-even.html)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 19, 2026; Oct 15, 2026 · Edited: Sep 19, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Combinatorics › Combinatorics in other fields › Combinatorics and probability

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/birthday-problem

English original: https://www.edgepedia.org/birthday-problem
