numpy.random.rayleigh

random.rayleigh(scale=1.0, size=None)

从瑞利分布中提取样本。

这个 \chi 威布尔分布是瑞利分布的推广。

注解

新代码应该使用 rayleigh A方法 default_rng() 请参阅 快速启动 .

参数
scale浮点数或类似浮点数的数组,可选

比例,也等于模式。必须为非负。默认值为1。

sizeint或int的元组,可选

输出形状。如果给定的形状是,例如, (m, n, k) 然后 m * n * k 取样。如果尺寸是 None (默认),如果 scale 是标量。否则, np.array(scale).size 取样。

返回
outndarray或scalar

从参数化瑞利分布中提取样本。

参见

Generator.rayleigh

应该用于新代码。

笔记

瑞利分布的概率密度函数是

System Message: WARNING/2 (p(x;scale)=\frac x scale^2 e \frac-x^2 2\cdotp scale^2)

latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2018-12-01> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2018/09/03 v1.4i Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...e^2 e \frac-x^2 2\cdotp scale^2\end{split} ! Package inputenc Error: Unicode character ; (U+FF1B) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...e^2 e \frac-x^2 2\cdotp scale^2\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...e^2 e \frac-x^2 2\cdotp scale^2\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...e^2 e \frac-x^2 2\cdotp scale^2\end{split} ! Package inputenc Error: Unicode character ; (U+FF1B) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...e^2 e \frac-x^2 2\cdotp scale^2\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...e^2 e \frac-x^2 2\cdotp scale^2\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 532 bytes). Transcript written on math.log.

例如,如果风速的东、北分量具有相同的零平均高斯分布,则会出现瑞利分布。然后风速会有瑞利分布。

工具书类

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 # random