欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

中心极限定理

程序员文章站 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()产生的是随机分布的点,由下图可知随机分布的点相减符合正态分布,其实相加也是。

中心极限定理