Details of this Paper

Week 5 HA - birthday_paradox;The [birthday paradox]( states that if there are 23 people in a room then there is a slightly...




Week 5 HA - birthday_paradox;The birthday paradox states that if there are 23 people in a room then there is a slightly more than 50:50 chance that at least two of them will have the same birthday. In this exercise you will write a BlueJ project (birthday_paradox) that will help us empirically test this non-intuitive result. Your project will have just one Java class BirthdayParadox. The details of this class are given below;?;?;o The following fields;o;? int[] days;? int numPeople;? int times;o A constructor BirthdayParadox(int numPeople, int numTimes) which takes as input parameters the number of people and the number of times the simulation is to be performed.;o int rndDay() // returns a random day i.e., a random integer from 1..365 (inclusive);o int once() // perform the simulation once;o void run() // After creating an instance of a BirthdayParadox object using the above constructor invoke the run method to run simulation;Your constructor for BirthdayParadox will take two inputs: the number of people we are testing for and the number of times to repeat the experiment. For each run of the experiment your program will print the number of people it randomly generated before a birthday repeated. It will print the average number of people after completing all the runs. Note that, by default, the BlueJ terminal window will only show the last 50 lines of a program. To show all the lines that are output by your program in the BlueJ terminal window, choose Options and select Unlimited buffering.;Following are two sample outputs of the program;Output for;2 people and 100 simulations;1 ---> 65;2 ---> 17;3 ---> 26;4 ---> 32;5 ---> 17...;96 ---> 47;97 ---> 27;98 ---> 15;99 ---> 22;100 ---> 24;Avg ---> 24.4;Output for;3 people and 200 simulations;1 ---> 89;2 ---> 40;3 ---> 98;4 ---> 36;5 ---> 38...;196 ---> 79;197 ---> 54;198 ---> 87;199 ---> 144;200 ---> 83;Avg ---> 86.7


Paper#64395 | Written in 18-Jul-2015

Price : $22