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()                                                                         #显示验证结果

python一行代码生成服从正态分布的随机数

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-08-31
  • 2022-02-24
  • 2022-12-23
  • 2021-04-11
相关资源
相似解决方案