您好,欢迎来到外链网!
当前位置:外链网 » 站长资讯 » 专业问答 » 文章详细 订阅RssFeed

python中randrange怎么用,python如何检验正态分布还是t分布

来源:互联网 浏览:60次 时间:2023-04-08

引用文章: numpy.random.randn()与numpy.random.rand()的区别
https://www.cnblogs.com/hezhiyao/p/8065528.html

总的来书就是, numpy.random.randn()生成的numpy矩阵元素值符合标准正态分布, 而numpy.random.rand()生成的是[0, 1)之间的均匀随机数.

[附]标准正态分布:
标准正态分布(英语:standard normal distribution, 德语Standardnormalverteilung),是一个在数学、物理及工程等领域都非常重要的概率分布,在统计学的许多方面有着重大的影响力。期望值μ=0,即曲线图象对称轴为Y轴,标准差σ=1条件下的正态分布,记为N(0,1)。

标准正态分布又称为u分布,是以0为均数、以1为标准差的正态分布,记为N(0,1)。

正态分布公式:
普通正态分布如何转换到标准正态分布
https://blog.csdn.net/bitcarmanlee/article/details/86440851
见numpy.random.randn() 官方doc结尾有应用案例.

- numpy.random.randn() 官方doc: Docstring:randn(d0, d1, ..., dn)Return a sample (or samples) from the "standard normal" distribution.If positive, int_like or int-convertible arguments are provided,`randn` generates an array of shape ``(d0, d1, ..., dn)``, filledwith random floats sampled from a univariate "normal" (Gaussian)distribution of mean 0 and variance 1 (if any of the :math:`d_i` arefloats, they are first converted to integers by truncation). A singlefloat randomly sampled from the distribution is returned if noargument is provided.This is a convenience function. If you want an interface that takes atuple as the first argument, use `numpy.random.standard_normal` instead.Parameters----------d0, d1, ..., dn : int, optional The dimensions of the returned array, should be all positive. If no argument is given a single Python float is returned.Returns-------Z : ndarray or float A ``(d0, d1, ..., dn)``-shaped array of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.See Also--------standard_normal : Similar, but takes a tuple as its argument.Notes-----For random samples from :math:`N(\mu, \sigma^2)`, use:``sigma * np.random.randn(...) + mu``Examples-------->>> np.random.randn()2.1923875335537315 #randomTwo-by-four array of samples from N(3, 6.25):>>> 2.5 * np.random.randn(2, 4) + 3array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], #random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) #randomType: builtin_function_or_method - numpy.random.rand() 官方doc: Docstring:rand(d0, d1, ..., dn)Random values in a given shape.Create an array of the given shape and populate it withrandom samples from a uniform distributionover ``[0, 1)``.Parameters----------d0, d1, ..., dn : int, optional The dimensions of the returned array, should all be positive. If no argument is given a single Python float is returned.Returns-------out : ndarray, shape ``(d0, d1, ..., dn)`` Random values.See Also--------randomNotes-----This is a convenience function. If you want an interface thattakes a shape-tuple as the first argument, refer tonp.random.random_sample .Examples-------->>> np.random.rand(3,2)array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #randomType: builtin_function_or_method 33988221