numpy.random.Generator.vonmises

方法

random.Generator.vonmises(mu, kappa, size=None)

从von mises分布中提取样本。

样本是从冯米塞斯分布中提取的,在间隔上具有指定的模式(mu)和分散度(kappa)。 [-pi, pi] .

冯米塞斯分布(又称圆正态分布)是单位圆上的连续概率分布。它可以被认为是正态分布的圆形类似物。

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

分布模式(“中心”)。

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

分布的分散度,必须大于等于0。

sizeint或int的元组,可选

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

返回
outndarray或scalar

从参数化von mises分布中提取样本。

参见

scipy.stats.vonmises

概率密度函数、分布或累积密度函数等。

笔记

冯米塞斯分布的概率密度是

System Message: WARNING/2 (p(x)=\frac e^ \kappa cos(x-\mu)2\p i i_0(\kappa),)

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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\end{split} ! Missing { inserted. <to be read again> } l.14 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\end{split} ! Undefined control sequence. <argument> ...=\frac e^ \kappa cos(x-\mu )2\p i i_0(\kappa ),\end ... l.14 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\end{split} ! Missing } inserted. <inserted text> } l.14 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\end{split} ! Missing { inserted. <to be read again> } l.14 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\end{split} ! Undefined control sequence. <argument> ...=\frac e^ \kappa cos(x-\mu )2\p i i_0(\kappa ),\end ... l.14 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\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 ...-\mu)2\p i i_0(\kappa),\end{split} ! Missing } inserted. <inserted text> } l.14 ...-\mu)2\p i i_0(\kappa),\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 448 bytes). Transcript written on math.log.

在哪里? \mu 是模式和 \kappa 分散,以及 I_0(\kappa) 是0阶的修正贝塞尔函数。

米塞斯是以理查德·埃德勒·冯·米塞斯命名的,他出生于奥匈帝国,现在的乌克兰。他于1939年逃到美国,成为哈佛大学的教授。他从事概率论、空气动力学、流体力学和科学哲学。

工具书类

1

Abramowitz,M.和Stegun,I.A.(编辑)。《数学函数与公式、图表和数学表手册》,第9版,纽约:多佛,1972年。

2

冯米塞斯,R.,“概率与统计的数学理论”,纽约:学术出版社,1964年。

实例

从分发中抽取样本:

>>> mu, kappa = 0.0, 4.0 # mean and dispersion
>>> s = np.random.default_rng().vonmises(mu, kappa, 1000)

显示样本的直方图,以及概率密度函数:

>>> import matplotlib.pyplot as plt
>>> from scipy.special import i0  
>>> plt.hist(s, 50, density=True)
>>> x = np.linspace(-np.pi, np.pi, num=51)
>>> y = np.exp(kappa*np.cos(x-mu))/(2*np.pi*i0(kappa))  
>>> plt.plot(x, y, linewidth=2, color='r')  
>>> plt.show()
../../../_images/numpy-random-Generator-vonmises-1.png