Implementing reinforcement learning in Python
Let's now move on to an example in which streaming data is used for Q-Learning. The data that we will be using is simulated data of stock prices:
- The data is generated in the following block of code.
The list of values that is first generated is a list of 30,000 consecutive values that represent stock prices. The data generating process is the starting point of 0 and at every time step, there is a random value added to this. The random normal values are centered around 0, which indicates that prices would go up or down by a step size based on a standard deviation of 1.
This process is often referred to as a random walk and it can go quite far up or down. After that, the values are standardized to be within a normal distribution again.
Code Block 8-1
import numpy as np import matplotlib.pyplot as plt import random starting = 0 values = [starting] for i in range(30000): values.append(values...