A random walk1 is a random process in which a state at time t is only dependent on the state at time t-1. Let us take a look at the following process:
with
Simulate a random walk of 100 steps using the standard normal distribution (i.e. with
rnorm()
. Store them in a vector called random_vals
.random_vals
to create a simple random walk based on the formula above. Store that in a vector called random_walk
.In order to validate your (random) results, we set a seed for R’s random number generator, which you can leave as is.