Question: (5) Simulation of coin tosses ram that simulates a sequence of tosses of a coin given the probability of heads Write a progr double p

 (5) Simulation of coin tosses ram that simulates a sequence of

(5) Simulation of coin tosses ram that simulates a sequence of tosses of a coin given the probability of heads Write a progr double p (in one toss) and the number of experiments int n; (see the explanation below) Fair and unfair coins: If a fair coin is tossed N times, then the relative frequency of heads (the number of times heads appear in N tosses divided by the number of experiments N) approaches to the probability of heads p 2 as N increases. In other words, heads come up in approximately a half of the tosses. The coin is called unfair if the probability of heads (in one toss) is p How to simulate a toss of a coin? Suppose that the probability of heads p E (0,1) is given. Let bool y be a variable which will contain the result of the simulation; the value true will correspond to 'heads' and false to 'tails'. First generate a (uniformly distributed) ran dom floating-point number r E [0, 1] employing the function rand ). If x

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 Databases Questions!