Question: Problem 2.(10 pts). Consider a 2D random walk: a man starts from the origin and has the equal probability moving to the left, right, upper

 Problem 2.(10 pts). Consider a 2D random walk: a man starts

Problem 2.(10 pts). Consider a 2D random walk: a man starts from the origin and has the equal probability moving to the left, right, upper and lower neighbor point with the step size 1. (a) (3 points) Write a function X=rwalk2d(n) that generates such a random for n steps. The output X being a 2-by-(n+1) vector should contain the position of each step where X (:,1) = [0;0). (b) (3 points) Write a script file called Plot Walk that plots a random walk by connecting each two adjacent steps by a black segment. Also mark the original and the last step in this random walk by a circle with red and blue color, respectively. (b) (4 points) Suppose during the n steps, this man will stop once he returns to the origin. Write a new function X rwalk2d0(n) for this new random walk. Run 100 experiments to estimate the probability that the man returns to the origin within 5 x 10 steps

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!