Question: 4. sharedBirthdays: The birthday problem is a question where most people's intuition is proved Incorrect by mathematics. The problem is: Given a group of N

 4. sharedBirthdays: The birthday problem is a question where most people's

4. sharedBirthdays: The birthday problem is a question where most people's intuition is proved Incorrect by mathematics. The problem is: Given a group of N people, how large must N be so that there is a 50% chance that at least 2 of the N people have the same birthday? Write a method with two parameters, the number of people in a group and the number of days in the year. The method will generate random birthdays for the number of people and then determine how many pairs of people have the same birthday. You don't have to generate actual days of the year for the birthdays. You can simply use ints. Here are two ways to generate random ints in Java. One uses an obieot of type Random and the other uses the random method from the Math class. // fiat approach Random r = new Random\"; int: max - 10.- int n = r.nexr_Int[mnx); 1/ x win now hold a vaiue between a and. 9 inclusive. 1/ The distribution of values in unitom. 1/ second approach int max - 10; int x = (int) (Hathaandumri * max],- If x will now hold a value between 0 and. 5 inclusive. 1/ The diatripution of values in uniform. If three people (Olivia, Kelly, Isabelle) share the same birthday, that is 3 pairs of people: 0 pair 1: Olivia and Kelly - pair 2: Olivia and Isabella - pair 3: Kelly and Isabelle 1- Perform an experiment simulating the birthday pram-n. Pick random birthdays for the given number at peepie. naturn the number of pairs of paopia that share the aama birthday. pre: numreapia > o, nunD-ysInEEar > a post: The number of pairs of people that share a birthday after randomly assigning birthdaya. '/ public atatie int eharedBizthdayalint nulnPeople, int numDeyaInYeaz) 1 After completing the method run the following experiments: Perform 1,000,000 experiments with 365 days per year and 182 people per experiment . What is the average number of pairs of people with shared birthdays? (Write a method to automate this experiment and put the code in CodeCamp.java.). Include your answer in a comment at the top of your CodeCampTester.java program. How many people do you think it takes so there is a 50% chance that at least 2 of the people have a shared birthday in a 365 day year? Perform 50,000 experiments with 365 days per year and vary the number of people from 2 to 100. 50,000 runs with 365 days, and 2 people, 50,000 runs with 365 days and 3 people, 50,000 runs with 385 days and 100 people. Total of 4,950,000 runs, 50,000 runs per experiments * 99 experiments 2 4,950,000 runs. For each of the given number of people determine the percentage of experiments where at least one pair of people shared a birthday. At what number of people (between 2 and 100) does the percentage first exceed 50%? Does the answer surprise you? How did It compare to your predicted answer? Include a table in a comment in your CodeCampTester.java program with the results of this experiment using the following format: nun paapiu 2, humour oi explrinsntl with on. or not: shared nirtnaay- izo, pare-ntagu 0.2a nun paapia: ion, numhar a: arparinanca with can or more aharaa birthday: auooo, percent-ya: 130.00 At the top of the tabte state how many people it requires to have a 50% chance of there being at least 1 shared birthday, given a 365 day year. Note, in the version of the program you turn in, list your results in a comment, but do not include any code that calls your methods that perform these experiments

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!