中心极限定理
程序员文章站
2022-07-10 23:33:03
...
中心极限定理指出了大量随机变量近似服从正态分布的条件。
import numpy as np
import matplotlib.pyplot as plt
N = 1000
x1 = np.zeros(N)
print(x1.shape)
for n in range(N):
x1[n] = np.sum(np.random.rand(12,1)) - np.sum(np.random.rand(12,1))
fig, ax = plt.subplots(figsize=(5,5)) #figuresize 指的是窗口尺寸
ax.hist(x1, 20)
plt.savefig('20.png')
np.random.rand()产生的是随机分布的点,由下图可知随机分布的点相减符合正态分布,其实相加也是。
上一篇: base64编码原理
下一篇: 从源码解析 Spring 数据库异常抽理