NAG Library Routine Document

g01faf  (inv_cdf_normal)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

g01faf returns the deviate associated with the given probability of the standard Normal distribution, via the routine name.

2
Specification

Fortran Interface
Function g01faf ( tail, p, ifail)
Real (Kind=nag_wp):: g01faf
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: p
Character (1), Intent (In):: tail
C Header Interface
#include nagmk26.h
double  g01faf_ ( const char *tail, const double *p, Integer *ifail, const Charlen length_tail)

3
Description

The deviate, xp associated with the lower tail probability, p, for the standard Normal distribution is defined as the solution to
PXxp=p=-xpZXdX,  
where
ZX=12πe-X2/2,   -<X< .  
The method used is an extension of that of Wichura (1988). p is first replaced by q=p-0.5.
(a) If q0.3, xp is computed by a rational Chebyshev approximation
xp=sAs2 Bs2 ,  
where s=2πq and A, B are polynomials of degree 7.
(b) If 0.3<q0.42, xp is computed by a rational Chebyshev approximation
xp=signq Ct Dt ,  
where t=q-0.3 and C, D are polynomials of degree 5.
(c) If q>0.42, xp is computed as
xp=signq Eu Fu +u ,  
where u = -2 × log minp,1-p  and E, F are polynomials of degree 6.
For the upper tail probability -xp is returned, while for the two tail probabilities the value xp* is returned, where p* is the required tail probability computed from the input value of p.

4
References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Wichura (1988) Algorithm AS 241: the percentage points of the Normal distribution Appl. Statist. 37 477–484

5
Arguments

1:     tail – Character(1)Input
On entry: indicates which tail the supplied probability represents.
tail='L'
The lower probability, i.e., PXxp.
tail='U'
The upper probability, i.e., PXxp.
tail='S'
The two tail (significance level) probability, i.e., PXxp+PX-xp.
tail='C'
The two tail (confidence interval) probability, i.e., PXxp-PX-xp.
Constraint: tail='L', 'U', 'S' or 'C'.
2:     p – Real (Kind=nag_wp)Input
On entry: p, the probability from the standard Normal distribution as defined by tail.
Constraint: 0.0<p<1.0.
3:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. 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:
If on exit ifail0, then g01faf returns 0.0.
ifail=1
On entry, tail=value.
Constraint: tail='L', 'U', 'S' or 'C'.
ifail=2
On entry, p=value.
Constraint: p<1.0.
On entry, p=value.
Constraint: p>0.0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

The accuracy is mainly limited by the machine precision.

8
Parallelism and Performance

g01faf is not threaded in any implementation.

9
Further Comments

None.

10
Example

Four values of tail and p are input and the deviates calculated and printed.

10.1
Program Text

Program Text (g01fafe.f90)

10.2
Program Data

Program Data (g01fafe.d)

10.3
Program Results

Program Results (g01fafe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017