Suppose we consider a simple random walk. A particle starts at initial position and moves one unit to the left with probability and moves one unit to the right with probability . What is the expected position of the particle after steps?

I will calculate the expected value using two different methods. The second method is simpler, but I’ll start using an iteration method.

Our PMF is:

Let’s set our initial position as:

After one step our expected position is then:

Great, let’s try iterating one more to see what we get. Note that at our position is now the result from , .

If we keep iterating we will see that . But we can prove this formally through induction. We’ve already done our base case, so let’s now do the induction step. We will assume that is true and show that it is also true for .

Thus our induction step holds and we have shown that .

Because we chose our initial starting position to be arbitrary, we might as well set it to 0 to obtain a final result of .

Let’s take a moment to think about this result and make sure it seems reasonable. Suppose . This would mean we have an equal chance of moving left or moving right. Over the long run we would expect our final position to be exactly where we started. Plugging in to our equation yields . Just as we expected! What if ? This means we only move to the left. Plugging into our equation yields . This makes sense! If we can only move to the left then after steps we would expect to be steps left of our staring position (the origin as we chose it), the negative direction in our problem setup. We could also choose to be 0, meaning we only move to the right and we would get , again just what we would expect!

We can also run a simulation in R to verify our results:

################################################################ # R Simulation ################################################################ # Generate random walk rand_walk = function (n, p, z) { walk = sample(c(-1,1), size=n, replace=TRUE, prob=c(p,1-p)) for (i in 1:n) { z = z + walk[i] } return(z) } n = 1000 # Walk n steps p = .3 # Probability of moving left z = 0 # Set initial position to 0 trials = 10000 # Num times to repeate sim # Run simulation X = replicate(trials, rand_walk(n,p,z)) # Calculate empirical and theoretical results empirical = mean(X) theoretical = n*(1-2*p) percent_diff = abs((empirical-theoretical)/empirical)*100 # print to console empirical theoretical percent_diff

Printing to the console we see that after 10,000 trials of 1,000 steps each our empirical and theoretical results differ by just 0.046%.

> empirical [1] 400.1842 > theoretical [1] 400 > percent_diff [1] 0.0460288

## 2 thoughts on “Simple Random Walk – Method 1”