Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Homework 2 CEN 4010 Spring 2017 A common use of random numbers is to simulate events using a program, rather than going through the time
Homework 2 CEN 4010 Spring 2017 A common use of random numbers is to simulate events using a program, rather than going through the time and expense of constructing a real-life experiment. For example, statistical theory tells us that the probability of having a tossed coin turn up heads is 0.5. Similarly, there is a 50 percent probability of having a single tossed coin turn up tails. Using these probabilities we would expect a single coin that is tossed 1000 times to turn up heads 500 times and tails 500 times. In practice, however, this is never exactly realized for a single experiment consisting of 1000 tosses. Instead of actually tossing a coinl000 times, however, we can use a random number generator to simulate these tosses. In particular, we could use any random number generator function that is available in the market or develop our own random number generator function. Let's assume we have developed afunction "rand that generates random numbers between 0 and 0.99. Using this normalized random number, we can simulate coin tosses for number of times until we get the desired output. We can use the following algorithm to develop our program: Initialize the heads count to zero Initialize the tail count to zero For 1000 times get a random number between 0 and 1 ifthe random number is greater than 0.5 consider this as a head and add one to the heads count else consider this as a tailand add one to the tails count end if enf for calculate the percentage of heads as the number of heads divided by 1000x100% calculate the percentage of tails as the number of tails divided by 1000x100% print the percentage of heads and tails obtained Design a software system that generates a random number (or calls random number generator function), then performs coin toss simulation
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started