Random Walk 1D
Program RandomWalk1d allows you to explore the properties of random walks in one dimension. Random walks are an example of a Bernoulli process for which there are two possible independent events (a step to the right or to the left). The distribution of walks in a particular direction is given by the binomial distribution. In addition, random walks are models of diffusion.ProblemMonte Carlo simulation of a one-dimensional random walk Program RandomWalk1d simulates a random walk in one dimension. A walker starts at the origin and takes $N$ steps. At each step the walker goes to the right with probability $p$ or to the left with probability $q = 1 - p$. Each step has the same unit length and is independent of the previous steps. Are some displacements more likely than others? We can simulate an $N$-step walk by the following pseudocode:
do istep = 1,N
$\,\,\,\,$if (rnd <= p) then
$\,\,\,\,\,\,\,\,$x = x + 1
$\,\,\,\,\,\,\,\,$x = x - 1
The function rnd generates a number between zero and one with equal probability. The quantity $x$ is the net displacement after $N$ steps assuming that the steps are of unit length.
We average over many walkers (trials), where each trial consists of a $N$ step walk and construct a histogram for the number of times that the displacement $x$ is found. The probability that the walker is a distance $x$ from the origin after $N$ steps is proportional to the corresponding value of the histogram. This procedure is called Monte Carlo sampling.
- Is the value of $x$ for one trial of any interest? Why do we have to average over many trials?
- Will we obtain the exact answer for the probability distribution by doing a Monte Carlo simulation?
- How does the histogram change for larger values of $N$. Assume $p=1/2$ here and in the following.
- What is the most probable value of $x$ for $N = 16$ and $N = 32$? Estimate the width of the distribution visually. How does the width change as a function of $N$?
- How does the histogram change, if at all, as the number of walkers increases for $N=4$?