学习目标:模拟布朗运动
学习内容:
1:导入必要库
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import scipy.stats
import random
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False
np.random.seed(0)
2:生成布朗运动
suijixulie=np.random.normal(loc=0, scale=1, size=1000)
bulangyundong=np.cumsum(suijixulie)
bulangyundong=np.insert(bulangyundong,0,0)
print(bulangyundong)
3:画图
plt.figure()
plt.plot(range(len(bulangyundong)),bulangyundong)
plt.title('布朗运动图像模拟')
plt.tight_layout()
plt.savefig('bulang.png',bbox_inches='tight',dpi=300)
plt.show()