版权声明:本文为博主原创文章,未经博主允许不得转载。保留追究法律责任,转载联系博主。交流欢迎加QQ群463339221。 https://blog.csdn.net/m0_37362454/article/details/82893055
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
n = 500
white_noise = np.random.standard_normal(size=n)
plt.plot(white_noise)
plt.title('White Noise')
random_walk = [0.0]
for i in range(n):
old_total_noise = random_walk[i]
new_noise = white_noise[i]
random_walk.append(old_total_noise + new_noise)
random_walk = np.array(random_walk)
plt.plot(random_walk)
plt.title("Random Walk")