randomVonMises¶
Generates pseudorandom numbers from a von Mises distribution.
Synopsis¶
randomVonMises (nRandom, c)
Required Arguments¶
- int
nRandom
(Input) - Number of random numbers to generate.
- float
c
(Input) - Parameter of the von Mises distribution. This parameter must be greater
than one-half of machine epsilon (On many machines, the lower bound for
c
is \(10^{-3}\)).
Return Value¶
An array of length nRandom
containing the random deviates of a von Mises
distribution.
Description¶
Function randomVonMises
generates pseudorandom numbers from a von Mises
distribution with parameter c
, which must be positive. With c = c
,
the probability density function is
for \(-\pi<x<\pi\), where \(I_0(c)\) is the modified Bessel function of the first kind of order 0. The probability density is equal to 0 outside the interval \(\left(-\pi,\pi\right)\).
The algorithm is an acceptance/rejection method using a wrapped Cauchy distribution as the majorizing distribution. It is due to Nest and Fisher (1979).
Example¶
In this example, randomVonMises
is used to generate five pseudorandom von
Mises variates with \(c=1\).
from numpy import *
from pyimsl.stat.randomVonMises import randomVonMises
from pyimsl.stat.randomSeedSet import randomSeedSet
from pyimsl.stat.writeMatrix import writeMatrix
n_random = 5
c = 1.0
randomSeedSet(123457)
r = randomVonMises(n_random, c)
writeMatrix("Von Mises random deviates", r, noColLabels=True)
Output¶
Von Mises random deviates
0.247 -2.433 -1.022 -2.172 -0.503