Java代写:CSE2100BirthdayParadox


编写程序证明 Birthday paradox ,也就是 生日悖论
证明方法很简单,随机生成n个人,随机生成他们的生日,然后测试就行了。

Birthday Paradox

The birthday paradox says that the probability that two people in a room will
have the same birthday is more than half, provided n, the number of people in
the room, is more than 23. This property is not really a paradox, but many
people find it surprising. Design a Java program that can test this paradox by
a series of experiments on randomly generated birthdays, which test this
paradox for n = 5, 10, 15, 20, …, 100.
For each n, run this experiment at least 100,000 times and see how many
experiments lead to the situation that at least two people have the same
birthday. Calculate the proportion of these experiments and use it as an
estimate of the probability.
For random number generator in Java. Check
http://stackoverflow.com/questions/5887709/getting­random­numbers­in­java
Note to save CPU time, you can exit an experiment once you already find two
people have the same birthday. This is a chance to use “break” statement.
You need to submit both source code and a typed report of the output of your
program. Note your report need to be a .pdf file.


文章作者: SafePoker
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 SafePoker !
  目录