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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:20, sosick90501
Write a function balancechemical to balance chemical reactions by solving a linear set of equations. the inputs arguments are: reagents: symbols of reagents in string row array products: symbols of products in string row array elements: elements in the reaction in string row array elcmpreag: elemental composition of reactants in two dimensional numeric array elcmpprdcts: elemental composition of prducts in two dimensional numeric array hint: the first part of the problem is setting up the set of linear equations that should be solve. the second part of the problem is to find the integers from the solution. one way to do this is to mulitiply the rational basis for the nullspace by increasing larger integers until both the left-and right-side integers exist. for example, for the reaction that involves reacting with to produce and : reagents=["ch4", "o2"]; products =["co2", "h2o"]; elements =["c","h", "o"] elcmpreag=[1,4,0;
Answers: 3
image
Computers and Technology, 23.06.2019 01:30, winstonbendariovvygn
1. which of the following is a search engine? a) mozilla firefox b)internet explorer c)google d)safari 2. which of the following statements is true? a) all search engines will provide the same results when you enter the same query. b) all search engines use the same amount of advertisements. c) some search engines are also browsers. d) search engines often provide different results, even when you enter the same query.
Answers: 2
image
Computers and Technology, 23.06.2019 01:50, rhonda45801
Free points just awnser this. what should i watch on netflix
Answers: 2
image
Computers and Technology, 23.06.2019 03:30, natalie2sheffield
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
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 in other subjects: