NAG FL Interface
g01faf (inv_​cdf_​normal)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g01faf returns the deviate associated with the given probability of the standard Normal distribution.

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 <nag.h>
double  g01faf_ (const char *tail, const double *p, Integer *ifail, const Charlen length_tail)
The routine may be called by the names g01faf or nagf_stat_inv_cdf_normal.

3 Description

The deviate, xp associated with the lower tail probability, p, for the standard Normal distribution is defined as the solution to
P(Xxp)=p=-xpZ(X)dX,  
where
Z(X)=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.
  1. (a)If |q|0.3, xp is computed by a rational Chebyshev approximation
    xp=sA(s2) B(s2) ,  
    where s=2πq and A, B are polynomials of degree 7.
  2. (b)If 0.3<|q|0.42, xp is computed by a rational Chebyshev approximation
    xp=signq (C(t) D(t) ) ,  
    where t=|q|-0.3 and C, D are polynomials of degree 5.
  3. (c)If |q|>0.42, xp is computed as
    xp=signq [(E(u) F(u) )+u] ,  
    where u = −2 × log(min(p,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

NIST Digital Library of Mathematical Functions
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., P(Xxp).
tail='U'
The upper probability, i.e., P(Xxp).
tail='S'
The two tail (significance level) probability, i.e., P(X|xp|)+P(X-|xp|).
tail='C'
The two tail (confidence interval) probability, i.e., P(X|xp|)-P(X-|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 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:
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 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

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)