The routine may be called by the names g01erf or nagf_stat_prob_vonmises.
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 and concentration parameter kappa, , can be written as
where is reduced modulo so that and . Note that if then g01erf returns a probability of . 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
where is the modified Bessel function. This series expansion can be represented as a nested expression of terms involving the modified Bessel function ratio ,
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 ,
and is computed from a continued fraction approximation. An approximation to order of the asymptotic normalizing series for is then used. Finally the Normal probability integral is evaluated.
For a more detailed analysis of the methods used see Hill (1977).
Hill G W (1977) Algorithm 518: Incomplete Bessel function : The Von Mises distribution ACM Trans. Math. Software3 279–284
Mardia K V (1972) Statistics of Directional Data Academic Press
1: – Real (Kind=nag_wp)Input
On entry: , the observed von Mises statistic measured in radians.
2: – Real (Kind=nag_wp)Input
On entry: the concentration parameter , of the von Mises distribution.
3: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, .
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
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 , the other gives an accuracy of digits and uses the Normal approximation when .
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g01erf is not threaded in any implementation.
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 if the region contains an odd multiple of , . The value of will be negative and the correct probability should then be obtained by adding one to the value.
This example inputs four values from the von Mises distribution along with the values of the parameter . The probabilities are computed and printed.