numpy.random.normal 函数   2018-09-11


numpy.random.normal 函数,有三个参数(loc, scale, size),代表生成的高斯分布随机数的均值、方差以及输出的 size.

例子:

np.random.normal(0, 0.05, (7,1)).astype(np.float32)

Output :

array([[-0.05229944],
[ 0.01754326],
[ 0.01764081],
[-0.03058357],
[-0.05406121],
[-0.07284269],
[ 0.00289147]], dtype=float32)

Scipy Help: numpy.random.normal

Parameters:	
loc : float or array_like of floats
Mean (“centre”) of the distribution.

scale : float or array_like of floats
Standard deviation (spread or “width”) of the distribution.

size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if loc and scale are both scalars. Otherwise, np.broadcast(loc, scale).size samples are drawn.

Returns:
out : ndarray or scalar
Drawn samples from the parameterized normal distribution.

Reference


分享到:


  如果您觉得这篇文章对您的学习很有帮助, 请您也分享它, 让它能再次帮助到更多的需要学习的人. 您的支持将鼓励我继续创作 !
本文基于署名4.0国际许可协议发布,转载请保留本文署名和文章链接。 如您有任何授权方面的协商,请邮件联系我。

Contents

  1. Reference