基本信息
源码名称:正态分布抽样代码.PY
源码大小:0.82KB
文件格式:.py
开发语言:Python
更新时间:2022-01-12
   源码介绍

正态分布抽样代码.PY


import numpy as np

import matplotlib.pyplot as plt

sampleNo = 10000
s = np.random.normal(0,0.2,sampleNo)
i = 0
sumall = 0
square =0
while i <sampleNo:
    sumall =sumall s[i]
    square = square s[i]*s[i]
    #print(i,'\t',s[i],'\t',sumall/(i 1),'\t',square)
    i = i 1

print(sumall/i)
plt.hist(s, 100)
plt.show()