Question
In Java. Your program should run 5000 trials. For each trial, it should generate 100 coin tosses and store them in an array; using the
In Java.
Your program should run 5000 trials. For each trial, it should generate 100 coin tosses and store them in an array; using the array, you can compute for that trial how many runs of 'hhhh' are followed by a head, and the ratio of the two numbers. For example, the following trial contains 9 runs of 'hhhh' but only 3 of them are followed by another 'h', giving us a ratio of 0.33333333333
After the 5000 trials the program should print the average of the ratios. You should expect that the average should be about 0.41.
Experiment with your code and see what happens as the trials get shorter (eg, 20 coin tosses) or longer (1000 or more). In all cases, make sure you are running at least 5000 trials, so that the averages that you compute are meaningful.
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