subject

The goal of this lab is to conduct an experiment to test the Birthday Paradox, vhich states that if 23 people gather, the chances are 50-50 that there are two people in the group having the same birthdays This days; that is, for any day of the year, the proportion of the people born on that day is 1/365 of the entire population. Under these assunptions, the probability that randomly selected 23 people have distinct birthdays from each other is: 365 364* * 343 In the denominator, there is no constraint about the birthdays; each person picks up one birthday from the 365 possibilities. In the numerator, the 23 people select birthdays one after another, so that no tvo have the sane birthdays: the first person has 365 possibilities, the second has 364 because he/she must not pick the one that the first person has chosen, the third person has 363 because he/ahe nust not pick the ones that the first and the second persons have chosen, and so on. The fraction is about 0.50, so the chances are almost 50-50 that there are two people having the same birthdays The centerpiece of the code is a method, oneTrial, that, given a number of people as its paraneter, randomly selects birthdays for those people and produces for each day how many people have chosen to have that birthday. More formally, the method has the number of people, nPeople, as its formal parameter and returns an int array. The method firat instantiates an array of 365 elements, say theCounts. Then, for nPeople tines (using a for-loop)the method selects a random integer between 0 and 364, and then increases the element of thecounts at the selected integer. After that it returns the array thecounts After receiving the return value of oneTrial, we examine the alots of the array for an entry greater or equal to 2. Such a alot indicates the existence of multiple having the same birthdays. We give this task to a nethod hasAHit. This nethod has its formal parameter an integer array and returns a boolean. Using a for-loop, the method scans the slots of the fornal paraneter. On encountering a slot value >2, the method returns true, thereby ignoring the remainder of the code in the method. After the for-loop, the method returns false, indicating that no slot -2 has been encountered Using the above two methods, we write another method, experiment1. The method experimentl has two formal paraneters. The first is an int by the name of nPeople, which is loop to count the executions of oneTrial. After each execution, w feed the return array of oneTrial to hasABit. If hasAHit returns true, we increase the value of a double proportion of the repetitions in which the random birthday selections generated multiple people having the sane birthdays. The method experimentl reports this ratio before The main method receives the quantities for nPeople and nReps and calls experimentl with these two values To print the average, use ".3f" in printf so that exactly three digits appear after the decinal point.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
Answers: 1
question
Computers and Technology, 23.06.2019 05:00
Which best explains why a digital leader would join a society specializing in technology
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
What makes myhexadecimalnumber a child of mynumber? which methods does myhexadecimalnumber inherit directly from the mynumber class? what can an instance of the mynumber class do? what can an instance of the myhexadecimalnumber class do? which methods are overridden? why are they overridden? how many examples of overloading are there? why was this done? where is the super keyword used? what is it doing? why isn’t the incoming value set immediately in the second myhexadecimalnumber constructor? how many examples can you find of an inherited method being called?
Answers: 1
question
Computers and Technology, 24.06.2019 03:00
Click the "draw structure" button to activate the drawing utility. draw two diastereomers of (1z,4r)−1,4−dimethylcyclodecene and name them, including (e)/(z) and (r)/(s) notation. part 1 out of 4 draw the diastereomer containing a chiral center with s configuration here. window open
Answers: 1
You know the right answer?
The goal of this lab is to conduct an experiment to test the Birthday Paradox, vhich states that if...
Questions
question
Mathematics, 13.11.2020 20:20
question
Mathematics, 13.11.2020 20:20
question
History, 13.11.2020 20:20
question
History, 13.11.2020 20:20
question
Chemistry, 13.11.2020 20:20
question
Biology, 13.11.2020 20:20
question
Social Studies, 13.11.2020 20:20