zoukankan      html  css  js  c++  java
  • numpy.matlib.randn(标准正态分布)

    #网址 http://docs.scipy.org/doc/numpy/reference/generated/numpy.matlib.randn.html#numpy.matlib.randn

    numpy.matlib.randn

    numpy.matlib.randn(*args)[source]

    Return a random matrix with data from the “standard normal” distribution.

    randn generates a matrix filled with random floats sampled from a univariate “normal” (Gaussian) distribution of mean 0 and variance 1.

    Parameters:

    *args : Arguments

    Shape of the output. If given as N integers, each integer specifies the size of one dimension. If given as a tuple, this tuple gives the complete shape.

    Returns:

    Z : matrix of floats

    A matrix of floating-point samples drawn from the standard normal distribution.

    See also

    rand, random.randn

    Notes

    For random samples from N(mu, sigma^2), use:

    sigma * np.matlib.randn(...) + mu

    Examples

    >>>
    >>> import numpy.matlib
    >>> np.matlib.randn(1)
    matrix([[-0.09542833]])                                 #random
    >>> np.matlib.randn(1, 2, 3) #和np.matlib.randn( 2, 3)产生相同的效果,不知道为什么要加1,另外不能产生维度更高的,比如np.matlib.randn( 2, 3,4)系统会报错
    matrix([[ 0.16198284,  0.0194571 ,  0.18312985],
            [-0.7509172 ,  1.61055   ,  0.45298599]])       #random
    

    Two-by-four matrix of samples from N(3, 6.25): #这点非常重要,知道如何产生其它方差和均值的分布; 2.5*2.5=6.25

    >>>
    >>> 2.5 * np.matlib.randn((2, 4)) + 3
    matrix([[ 4.74085004,  8.89381862,  4.09042411,  4.83721922],
            [ 7.52373709,  5.07933944, -2.64043543,  0.45610557]])  #random
    

    Previous topic

    numpy.matlib.rand

    Next topic

    Miscellaneous routines

  • 相关阅读:
    nosql----redis持久化详解
    linux下发送邮件
    自动化运维工具----ansiable安装与配置
    nginx----统计网站访问量
    机试指南第二章-经典入门-排序例题自解
    机试指南第二章-经典入门-排序模板
    Theano入门
    OpenJudge 4120 硬币
    OpenJudge 1088 滑雪
    OpenJudge 4152 最佳加法表达式
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/5335902.html
Copyright © 2011-2022 走看看