Simulating 1D random walk

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:

  1. Start from position 0
  2. Randomly select a number with a value of -1 or 1
  3. Add it to the observation of the previous time step
  4. Repeat these steps from step 2

To implement this algorithm in Python, just refer ...

Get Keras Reinforcement Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.