NAG FL Interface
g01erf (prob_​vonmises)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g01erf returns the probability associated with the lower tail of the von Mises distribution between -π and π through the function name.

2 Specification

Fortran Interface
Function g01erf ( t, vk, ifail)
Real (Kind=nag_wp) :: g01erf
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: t, vk
C Header Interface
#include <nag.h>
double  g01erf_ (const double *t, const double *vk, Integer *ifail)
The routine may be called by the names g01erf or nagf_stat_prob_vonmises.

3 Description

The von Mises distribution is a symmetric distribution used in the analysis of circular data. The lower tail area of this distribution on the circle with mean direction μ0=0 and concentration parameter kappa, κ, can be written as
Pr(Θθ:κ)=12πI0(κ) -πθeκcosΘdΘ,  
where θ is reduced modulo 2π so that -πθ<π and κ0. Note that if θ=π then g01erf returns a probability of 1. For very small κ the distribution is almost the uniform distribution, whereas for κ all the probability is concentrated at one point.
The method of calculation for small κ involves backwards recursion through a series expansion in terms of modified Bessel functions, while for large κ an asymptotic Normal approximation is used.
In the case of small κ the series expansion of Pr(Θθ: κ) can be expressed as
Pr(Θθ:κ)=12+θ (2π) +1πI0(κ) n=1n-1In(κ)sinnθ,  
where In(κ) is the modified Bessel function. This series expansion can be represented as a nested expression of terms involving the modified Bessel function ratio Rn,
Rn(κ)=In(κ) In-1(κ) ,  n=1,2,3,,  
which is calculated using backwards recursion.
For large values of κ (see Section 7) an asymptotic Normal approximation is used. The angle Θ is transformed to the nearly Normally distributed variate Z,
Z=b(κ)sinΘ2,  
where
b(κ)=2π eκ I0(κ)  
and b(κ) is computed from a continued fraction approximation. An approximation to order κ−4 of the asymptotic normalizing series for z is then used. Finally the Normal probability integral is evaluated.
For a more detailed analysis of the methods used see Hill (1977).

4 References

Hill G W (1977) Algorithm 518: Incomplete Bessel function I0: The Von Mises distribution ACM Trans. Math. Software 3 279–284
Mardia K V (1972) Statistics of Directional Data Academic Press

5 Arguments

1: t Real (Kind=nag_wp) Input
On entry: θ, the observed von Mises statistic measured in radians.
2: vk Real (Kind=nag_wp) Input
On entry: the concentration parameter κ, of the von Mises distribution.
Constraint: vk0.0.
3: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, vk=value.
Constraint: vk0.0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

g01erf uses one of two sets of constants depending on the value of machine precision. One set gives an accuracy of six digits and uses the Normal approximation when vk6.5, the other gives an accuracy of 12 digits and uses the Normal approximation when vk50.0.

8 Parallelism and Performance

g01erf is not threaded in any implementation.

9 Further Comments

Using the series expansion for small κ the time taken by g01erf increases linearly with κ; for larger κ, for which the asymptotic Normal approximation is used, the time taken is much less.
If angles outside the region -πθ<π are used care has to be taken in evaluating the probability of being in a region θ1θθ2 if the region contains an odd multiple of π, (2n+1)π. The value of F(θ2;κ)-F(θ1;κ) will be negative and the correct probability should then be obtained by adding one to the value.

10 Example

This example inputs four values from the von Mises distribution along with the values of the parameter κ. The probabilities are computed and printed.

10.1 Program Text

Program Text (g01erfe.f90)

10.2 Program Data

Program Data (g01erfe.d)

10.3 Program Results

Program Results (g01erfe.r)