Numpy random.normal 从参数化的正太分布中抽取样本

举报
千江有水千江月 发表于 2021/12/20 12:21:04 2021/12/20
【摘要】 环境信息ModelArtsCodeLabConda-python3numpy 1.19.1  代码示例import numpy as np# normal 正态分布# loc 均值、中心点# scale 标准差# size shapenp.random.normal(loc=0.0,scale=0.5,size=(2,3))array([[ 0.10619526, -0.39647814,...

环境信息

  • ModelArts
    • CodeLab
      • Conda-python3
        • numpy 1.19.1

代码示例

import numpy as np
# normal 正态分布
# loc 均值、中心点
# scale 标准差
# size shape
np.random.normal(loc=0.0,scale=0.5,size=(2,3))

array([[ 0.10619526, -0.39647814,  0.40132629],
       [-0.67939799,  0.17557369,  0.35635957]])
np.random.normal(loc=0.0,scale=0.5,size=(2,3))

array([[-0.12602457, -0.18214869,  0.41834138],
       [-0.14308624, -0.03331257,  0.44946082]])

源码学习

help(np.random.normal)

Help on built-in function normal:

normal(...) method of numpy.random.mtrand.RandomState instance
    normal(loc=0.0, scale=1.0, size=None)
    
    Draw random samples from a normal (Gaussian) distribution.
    
    The probability density function of the normal distribution, first
    derived by De Moivre and 200 years later by both Gauss and Laplace
    independently [2]_, is often called the bell curve because of
    its characteristic shape (see the example below).
    
    The normal distributions occurs often in nature.  For example, it
    describes the commonly occurring distribution of samples influenced
    by a large number of tiny, random disturbances, each with its own
    unique distribution [2]_.
    
    .. note::
        New code should use the ``normal`` method of a ``default_rng()``
        instance instead; please see the :ref:`random-quick-start`.

......        

备注

  1. 欢迎各位同学一起来交流学习心得^_^
  2. 在线课程、沙箱实验、认证、大赛、论坛和直播,其中包含了许多优质的内容,推荐了解与学习。
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。