Question: Sky performs a random walk from his home. He makes a random decision to go either up, down, left or right in each step. If

Sky performs a random walk from his home. He makes a random decision to go either up, down, left or right in each step. If he is more than 4 blocks away from his home, he will need to take transport back home; otherwise, he walks home. Sky coordinate is 64 home is 00

The question is:

What is the longest random walk he can take so there is more than a 50% chance he can go home on a walk?

Note that the length of the random walk is the total number of steps of the path, and the distance from home is IxI + lyl.

output:

the longest random walk = 12

the chance of walking home = 51.03%

No. of iterations used in the simulation = ?

Write a Monte Carlo simulation program to find the answer to the above question. If your program runs correctly, it should output the following answer, in which the estimated percentage may vary but is close to 51%. The last value, no. of iterations, is a simulation parameter you need to estimate by yourself and display in the output. The value indicates the number of iterations used to estimate the walk-home-chance for a random walk of a particular length.

Requirements for your program:

  1. Output the correct answer.
  2. Demonstrate Object-Oriented programdesign.
  3. Follow Java naming convention and programming style.
  4. Any other classes should be private static classes inside the main class.

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!