# random_walk_2d_simulation

random_walk_2d_simulation, a Python code which simulates a random walk in a 2D region.

random_walk_2d_plot() plots the trajectories of one or more random walks.

random_walk_2d_simulation() plots averaged data for any number of random walks that each use the same number of steps. The data plotted is the average and maximum of the distance squared at each time step. The average distance squared should behave like the number of time steps.

### Usage:

random_walk_2d_plot ( step_num, walk_num )
where
• step_num is the number of steps to take. 500 might be a typical value.
• walk_num is the number of random walks to take. Each walk is displayed on a common grid.

random_walk_2d_simulation ( step_num, walk_num )
where
• step_num is the number of steps to take. 500 might be a typical value.
• walk_num is the number of random walks to take. The data that is plotted comes from the average over all these walks.

### Languages:

random_walk_2d_simulation is available in a MATLAB version and an Octave version and a Python version.

### Related Data and codes:

python_simulation, a Python code which uses simulation to study card games, contests, and other processes which have a random element. Usually, the purpose is to try to predict the average behavior of the system over many trials.

### Reference:

1. Martin Gardner,
The Mathematical Circus,
Mathematics Association of America, 1996,
ISBN13: 978-0883855065,
LC: QA95.G287.
2. Ian Stewart,
"Repealing the Law of Averages",
Scientific American,
Volume 278, Number 4, April 1998, pages 102-104.

### Source Code:

Last revised on 27 November 2022.