hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_rand_dist_vonmises (g05sr)

Purpose

nag_rand_dist_vonmises (g05sr) generates a vector of pseudorandom numbers from a von Mises distribution with concentration parameter κκ.

Syntax

[state, x, ifail] = g05sr(n, vk, state)
[state, x, ifail] = nag_rand_dist_vonmises(n, vk, state)

Description

The von Mises distribution is a symmetric distribution used in the analysis of circular data. The PDF (probability density function) of this distribution on the circle with mean direction μ0 = 0μ0=0 and concentration parameter κκ, can be written as:
f(θ) = (eκcosθ)/(2πI0(κ)),
f(θ)= eκcosθ 2πI0(κ) ,
where θθ is reduced modulo 2π2π so that πθ < π-πθ<π and κ0κ0. For very small κκ the distribution is almost the uniform distribution, whereas for κκ all the probability is concentrated at one point.
The nn variates, θ1,θ2,,θnθ1,θ2,,θn, are generated using an envelope rejection method with a wrapped Cauchy target distribution as proposed by Best and Fisher (1979) and described by Dagpunar (1988).
One of the initialization functions nag_rand_init_repeat (g05kf) (for a repeatable sequence if computed sequentially) or nag_rand_init_nonrepeat (g05kg) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_dist_vonmises (g05sr).

References

Best D J and Fisher N I (1979) Efficient simulation of the von Mises distribution Appl. Statist. 28 152–157
Dagpunar J (1988) Principles of Random Variate Generation Oxford University Press
Mardia K V (1972) Statistics of Directional Data Academic Press

Parameters

Compulsory Input Parameters

1:     n – int64int32nag_int scalar
nn, the number of pseudorandom numbers to be generated.
Constraint: n0n0.
2:     vk – double scalar
κκ, the concentration parameter of the required von Mises distribution.
Constraint: 0.0 < vksqrt(x02al) / 2.00.0<vkx02al/2.0.
3:     state( : :) – int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains information on the selected base generator and its current state.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     state( : :) – int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains updated information on the state of the generator.
2:     x(n) – double array
The nn pseudorandom numbers from the specified von Mises distribution.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry, n < 0n<0.
  ifail = 2ifail=2
On entry,vk0.0vk0.0,
orvk > sqrt(x02al()) / 2.0vk>x02al()/2.0.
  ifail = 3ifail=3
On entry,state vector was not initialized or has been corrupted.

Accuracy

Not applicable.

Further Comments

For a given number of random variates the generation time increases slightly with increasing κκ.

Example

function nag_rand_dist_vonmises_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);
n = int64(5);
vk = 1;
% Initialize the generator to a repeatable sequence
[state, ifail] = nag_rand_init_repeat(genid, subid, seed);
[state, x, ifail] = nag_rand_dist_vonmises(n, vk, state)
 

state =

                   17
                 1234
                    1
                    0
                21822
                24586
                30912
                13308
                17917
                13895
                19930
                    8
                    0
                 1234
                    1
                    1
                 1234


x =

    1.2947
   -1.9542
   -0.6464
   -1.4172
    1.2536


ifail =

                    0


function g05sr_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);
n = int64(5);
vk = 1;
% Initialize the generator to a repeatable sequence
[state, ifail] = g05kf(genid, subid, seed);
[state, x, ifail] = g05sr(n, vk, state)
 

state =

                   17
                 1234
                    1
                    0
                21822
                24586
                30912
                13308
                17917
                13895
                19930
                    8
                    0
                 1234
                    1
                    1
                 1234


x =

    1.2947
   -1.9542
   -0.6464
   -1.4172
    1.2536


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013