numpy.random.rayleigh¶
-
numpy.random.
rayleigh
(scale=1.0, size=None)¶ 从瑞利分布中提取样本。
这个 \chi 威布尔分布是瑞利分布的推广。
参数: - 规模 : 浮点数或类似浮点数的数组,可选
比例,也等于模式。应大于等于0。默认值为1。
- size : int或int的元组,可选
输出形状。如果给定的形状是,例如,
(m, n, k)
然后m * n * k
取样。如果尺寸是None
(默认),如果scale
是标量。否则,np.array(scale).size
取样。
返回: - out : ndarray或scalar
从参数化瑞利分布中提取样本。
笔记
瑞利分布的概率密度函数是
p(x;scale)=frac x scale^2 e frac-x^2 2cdotp scale^2
例如,如果风速的东、北分量具有相同的零平均高斯分布,则会出现瑞利分布。然后风速会有瑞利分布。
工具书类
[1] Brighton Webs有限公司,“瑞利分销”,https://web.archive.org/web/20090514091424/http://brighton webs.co.uk:80/distributions/rayleigh.asp [2] 维基百科,“瑞利发行版”https://en.wikipedia.org/wiki/rayleigh_发行版 实例
从分布中绘制值并绘制柱状图
>>> from matplotlib.pyplot import hist >>> values = hist(np.random.rayleigh(3, 100000), bins=200, density=True)
波高往往遵循瑞利分布。如果平均波高为1米,那么波的哪一部分可能大于3米?
>>> meanvalue = 1 >>> modevalue = np.sqrt(2 / np.pi) * meanvalue >>> s = np.random.rayleigh(modevalue, 1000000)
大于3米的波浪百分比为:
>>> 100.*sum(s>3)/1000000. 0.087300000000000003