Numpy random函数

import numpy as np
# 生成一个随机数组
np.random.randint(0,6,3)
# array([1, 1, 3])

# 生成一个随机数组(二维数组)
np.random.randint(0,6,(3,3))
'''
array([[4, 4, 1],
       [2, 1, 0],
       [5, 0, 0]])
'''
# 生成十个随机数在[0,1)之间
np.random.rand(10)
'''
array([0.9283789 , 0.43515554, 0.27117021, 0.94829333, 0.31733981,
       0.42314939, 0.81838647, 0.39091899, 0.33571004, 0.90240897])
'''
# 从标准正态分布中随机抽选出3个数
np.random.standard_normal(3)
# array([0.34660435, 0.63543859, 0.1307822 ])
# 返回三页四行两列的标准正态分布数
np.random.standard_normal((3,4,2))
'''
array([[[-0.24880261, -1.17453957],
        [ 0.0295264 ,  1.04038047],
        [-1.45201783,  0.57672288],
        [ 1.10282747, -2.08699482]],

       [[-0.3813943 ,  0.47845782],
        [ 0.97708005,  1.1760147 ],
        [ 1.3414987 , -0.629902  ],
        [-0.29780567,  0.60288726]],

       [[ 1.43991349, -1.6757028 ],
        [-1.97956809, -1.18713495],
        [-1.39662811,  0.34174275],
        [ 0.56457553, -0.83224426]]])
'''

2020-05-07

上一篇:VIM - 宏 - 简单使用


下一篇:C# PictureBox.SizeMode 属性