Advertisement

Numpy模块:随机数

阅读量:

作为数据分析过程中不可或缺的辅助工具,numpy.random模块提供了多种概率分布下的随机样本生成功能。

高斯分布(一般指正态分布)

np.random.normal(loc=0.0, scale=1.0, size=None)

复制代码
    samples = np.random.normal(size=(4,4))
    samples2 = np.random.normal(size=(1,4))
    print(samples)
    print(samples2)
    =================
    [[ 0.35662443  1.60926491 -0.39375014 -1.51393004]
     [ 0.32282414 -0.76187263 -0.5410377   1.51626327]
     [-0.55840719 -0.75991083  0.08888547  0.6182852 ]
     [-0.76060378  2.03292748 -1.50225913  0.86965216]]
    [[ 0.28836116 -0.29002298  1.21264748  1.89623666]]
    
    
    AI写代码python

全部评论 (0)

还没有任何评论哟~