We have previously said that a random walk contains a random term. To simulate a random walk, it is not enough to generate a list of random numbers, because the next value in the sequence is a modification of the previous value. This dependency provides a certain coherence from one passage to the next that does not happen in the generation of independent random numbers, which instead shows great jumps from one number to the next.
A simple model of a casual walk can be simulated through the following pseudocode:
- Start from position 0
- Randomly select a number with a value of -1 or 1
- Add it to the observation of the previous time step
- Repeat these steps from step 2
To implement this algorithm in Python, just refer ...