Question

3. In this question we simulate the rolling of a die. To do this we use the func- tion runif (1),which returns a randomnumber in the range (0,1). To get a random integer in the range (1,2,3,4,5,6), we use ceiling(6 runif (1)) or if you prefer, sarple(1:6,size-1) will do the same job. (a). Suppose that you are playing the gambling game of the Chevalier de Méré. That is, you are betting that you get at least one six in 4 throws and of a die. Write a program prints out whether you win or lose. that simulates one round of this game Check that your program can produce a different result each time you run (b). Turn the program that you wrote in part (a) into a function sixes, which returns TRUE if you obtain at least one six in n rolls of a fair die, and returns FALSE otherwise. That is, the argument is the number of rolls n, and the value retued is TRUE if you get at least one six and FALSE otherwise How would you give n the default value of 4? EXERCISES 79 (c).Now write a program that uses your function sixes from part (b). to simulate N plays of the game (each time you bet that you get at least 1 six in n rolls of a fair die). Your program should then determine the proportion of times you win the bet. This proportion is an estimate of the probability of getting at least one 6 in n rolls of a fair die Run the program for 4 and N 100, 1000, and 10000, conducting several runs for each N value. How does the variability of your results depend on N? The probability of getting no 6s in n rolls of a fair die is (5/6), so the probability of getting at least one is 1 - (5/6). Modify your program so that it calculates the theoretical probability as well as the simulation estimate and prints the difference between them. How does the accurucy of your results depend on N? You may find the replicate function useful here

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
3. In this question we simulate the rolling of a die. To do this we use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT