random_von_mises

Generates pseudorandom numbers from a von Mises distribution.

Synopsis

#include <imsls.h>

float *imsls_f_random_von_mises(int n_random, float c, 0)

The type double function is imsls_d_random_von_mises.

Required Arguments

int n_random (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 n_random containing the random deviates of a von Mises distribution.

Synopsis with Optional Arguments

#include <imsls.h>

float *imsls_f_random_von_mises (int n_random, float c,
IMSLS_RETURN_USER, float r[],
0)

Optional Arguments

IMSLS_RETURN_USER, float r[] (Output)
User-supplied array of length n_random containing the random von Mises deviates.

Description

Function imsls_f_random_von_mises generates pseudorandom numbers from a von Mises distribution with parameter c, which must be positive. With c = c, the probability density function is

 

for −π < x < π, where I0 (c) is the modified Bessel function of the first kind of order 0. The probability density is equal to 0 outside the interval (−ππ).

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, imsls_f_random_von_mises is used to generate five pseudorandom von Mises variates with c = 1.

 

#include <imsls.h>

 

int main()

{

int n_random = 5;

float c = 1.0;

float *r;

 

imsls_random_seed_set(123457);

 

r = imsls_f_random_von_mises(n_random, c,

0);

 

imsls_f_write_matrix("Von Mises random deviates:", 1, n_random, r,

IMSLS_NO_COL_LABELS,

0);

}

Output

 

Von Mises random deviates:

0.247 -2.433 -1.022 -2.172 -0.503