Question: In a three - dimensional random walk, the position ( x , y , z ) of a walker at step j is computed by:

In a three-dimensional random walk, the position (x, y, z) of a walker at step j is computed
by: xj = xj-1+\Delta x, yj = yj-1+\Delta y and zj = zj-1+\Delta z, where \Delta x,\Delta y, and \Delta z are random numbers
that determine the length and direction of each step. Assume that the walker starts at the
origin, and keeps taking steps (each of random length and direction) until they step outside of
a boundary. The boundary is a sphere of radius R =15 centered at the origin.
a. Write a Matlab script (m-file) that calculates the number of steps required for the walker
to reach the boundary. Use Matlabs built-in function randn(1,1) to calculate \Delta x,\Delta y, and
\Delta z. Run the program 500 times (using a loop) and calculate the average number of steps
needed to reach the boundary. Output the results to the user.
b. Write a Matlab script (m-file) that creates a three-dimensional plot of a single random
walk. Use Matlabs built-in function randn(1,1) to calculate \Delta x,\Delta y, and \Delta z. Use
Matlabs built-in function plot3 to create the plot. Be sure to add a title and axis labels to
the plot.

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 Finance Questions!