In probability theory, the birthday problem, or birthday paradox This not a paradox in the sense of leading to a logical contradiction, but is called a paradox because the mathematical truth contradicts naive intuition: most people estimate that the chance is much lower than 50%. pertains to the probalility that in a set of randomly chosen people some pair of them will have the same birthday. In a group of at least 23 randomly chosen people, there is more than 50% probalility that some pair of them will both have been born on the same day. For 57 or more people, the probability is more than 99%, and it reachese 100% when the number of people reaches 366 (by the pigeon hole principle, ignoring leap yeas). The mathematics behind this problem lead to a well-known cryptographic attack call the birthday attack.
Using simulation, estimate the number of independent people required in a groups before we can expect a better than even chance that at least 2 independent people in a group share a common birthday. Furthermore: Simulate and thus estimate when we can expect a better than even chance that at least 3, 4 & 5 independent people of the group share a common birthday. For simplicity assume that all of the people are alive…
¶Calculating the probalility
数学概率推导方法,
1 | fn probe(n: i32) { |
¶Birthday Attack
生日悖论可以描述为:在N个人中,想使至少由两个人生日相同的概率大于50%,问N的最小值是多少?答案是23人。
1 | use rand::prelude::*; |