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:
- Output the correct answer.
- Demonstrate Object-Oriented programdesign.
- Follow Java naming convention and programming style.
- Any other classes should be private static classes inside the main class.
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