Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.random.RandomState.vonmises

RandomState.vonmises(mu,kappa,size=None)

Draw samples from a von Mises distribution.

Samples are drawn from a von Mises distribution with specified mode(mu) and dispersion (kappa), on the interval [-pi, pi].

The von Mises distribution (also known as the circular normaldistribution) is a continuous probability distribution on the unitcircle. It may be thought of as the circular analogue of the normaldistribution.

Parameters:

mu : float or array_like of floats

Mode (“center”) of the distribution.

kappa : float or array_like of floats

Dispersion of the distribution, has to be >=0.

size : int or tuple of ints, optional

Output shape. If the given shape is, e.g.,(m,n,k), thenm*n*k samples are drawn. If size isNone (default),a single value is returned ifmu andkappa are both scalars.Otherwise,np.broadcast(mu,kappa).size samples are drawn.

Returns:

out : ndarray or scalar

Drawn samples from the parameterized von Mises distribution.

See also

scipy.stats.vonmises
probability density function, distribution, or cumulative density function, etc.

Notes

The probability density for the von Mises distribution is

p(x) = \frac{e^{\kappa cos(x-\mu)}}{2\pi I_0(\kappa)},

where\mu is the mode and\kappa the dispersion,andI_0(\kappa) is the modified Bessel function of order 0.

The von Mises is named for Richard Edler von Mises, who was born inAustria-Hungary, in what is now the Ukraine. He fled to the UnitedStates in 1939 and became a professor at Harvard. He worked inprobability theory, aerodynamics, fluid mechanics, and philosophy ofscience.

References

[R204]Abramowitz, M. and Stegun, I. A. (Eds.). “Handbook ofMathematical Functions with Formulas, Graphs, and MathematicalTables, 9th printing,” New York: Dover, 1972.
[R205]von Mises, R., “Mathematical Theory of Probabilityand Statistics”, New York: Academic Press, 1964.

Examples

Draw samples from the distribution:

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

Display the histogram of the samples, along withthe probability density function:

>>>importmatplotlib.pyplotasplt>>>fromscipy.specialimporti0>>>plt.hist(s,50,normed=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()

(Source code)

Previous topic

numpy.random.RandomState.uniform

Next topic

numpy.random.RandomState.wald

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp