See Part 1. I’ve been exploring a random walk in one dimension, where on object moves either +1 or −1 at each step, at random. On average, it will end up back near where it started (distance = 0), but over time, the likely positions start to spread out. I previously graphed the outcome of 1000 trials for 2000 steps. Although I can see the trajectories start to spread out, I’d like to actually graph the distribution.

**Problem: **Graph the probability of an object ending up at different distances from the origin during a random walk.

First, let’s look at the outcome of 1000 trials for 2000 steps. This is the same graph as from the previous post.

Now, let’s look at the final positions of all the trajectories after the 2000 steps. I’ll plot a histogram of the frequency of finding an object at that position.

As you can see, most objects end up near the origin (distance = 0), and it drops off towards a probability of 0 in either direction. The shape is familiar: it is the so-called “bell curve,” or normal distribution. The dashed line is a plot of the normal distribution with mean = 0 and standard deviation = √(2000 )(the number of steps).

Let’s compare how this distribution changes over time — I’ll select 500, 1000, and 2000 steps as the points at which to graph the distance distribution, indicated by the red, green, and blue lines below.

The blue line of course represents the final positions, already graphed above. Here are all three distributions, superimposed on the same graph:

Each histogram is paired with the predicted distribution. You can see that after 500 steps (red), most objects are clustered near the origin. After 1000 steps (green), they are more spread out, and after 2000 steps (blue, also seen above), they are even more spread out. The spread increases as the square root of the number of steps, which can again be seen visually on this graph from the prior post:

### Like this:

Like Loading...

## One thought on “Random Walk in One Dimension, Part 2”

Comments are closed.