numpy.random.wald

random.wald(mean, scale, size=None)

从瓦尔德分布或逆高斯分布中提取样本。

当比例接近无穷大时,分布变得更像是高斯分布。一些参考文献声称wald是一个平均值等于1的逆高斯,但这绝不是普遍的。

首先研究了逆高斯分布与布朗运动的关系。1956年,M.C.K.Tweedie使用了逆高斯这个名字,因为覆盖单位距离的时间和覆盖单位时间的距离之间存在着逆关系。

注解

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

参数
mean浮点数或类似浮点数的数组

分布平均值,必须大于0。

scale浮点数或类似浮点数的数组

比例参数,必须大于0。

sizeint或int的元组,可选

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

返回
outndarray或scalar

从参数化瓦尔德分布中提取样本。

参见

Generator.wald

应该用于新代码。

笔记

瓦尔德分布的概率密度函数是

System Message: WARNING/2 (P(x;平均值,标度)=\sqrt{\frac{scale}{2\pix^3}}e^)

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 ...=\sqrt{\frac{scale}{2\pix^3}}e^\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 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 平 (U+5E73) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 均 (U+5747) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 值 (U+503C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 标 (U+6807) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 度 (U+5EA6) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\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 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Undefined control sequence. <argument> 2\pix ^3 l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Missing { inserted. <to be read again> } l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Missing } inserted. <inserted text> } l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\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 ...=\sqrt{\frac{scale}{2\pix^3}}e^\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 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 平 (U+5E73) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 均 (U+5747) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 值 (U+503C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 标 (U+6807) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Package inputenc Error: Unicode character 度 (U+5EA6) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\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 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Undefined control sequence. <argument> 2\pix ^3 l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Missing { inserted. <to be read again> } l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} ! Missing } inserted. <inserted text> } l.14 ...=\sqrt{\frac{scale}{2\pix^3}}e^\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 476 bytes). Transcript written on math.log.

如上所述,逆高斯分布首先来自对布朗运动的建模。它也是威布尔的竞争对手,用于可靠性建模和股票收益和利率过程建模。

工具书类

1

Brighton Webs有限公司,Wald发行,https://web.archive.org/web/20090423014010/http://www.brighton-webs.co.uk:80/distributions/wald.asp

2

《逆高斯分布:理论:方法论与应用》,Chhikara,Raj S.与Feeks,J.Leroy出版社,1988年。

3

维基百科,“反向高斯分布”https://en.wikipedia.org/wiki/Inverse_Gaussian_Distribution

实例

从分布中绘制值并绘制柱状图:

>>> import matplotlib.pyplot as plt
>>> h = plt.hist(np.random.wald(3, 2, 100000), bins=200, density=True)
>>> plt.show()
../../../_images/numpy-random-wald-1.png