热线电话:13121318867

登录
2020-11-18 阅读量: 1263
Python如何生成服从正态分布的随机数?

1)生成随机数

import numpy as np #导入库

random3 = numpy.random.randn(10000) #随机生成10000个服从正态分布的随机数

2)结果验证

import seaborn as sns #使用seaborn 库画直方图验证结果

sns.set_palette("hls") #设置所有图的颜色,使用hls色彩空间
sns.distplot(random3,color="r",bins=1000,kde=True) #绘制直方图,color设置颜色,bins设置直方图的划分数
plt.show() #显示验证结果


42.4651
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子