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_stat_inv_cdf_normal (g01fa)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_inv_cdf_normal (g01fa) returns the deviate associated with the given probability of the standard Normal distribution.

Syntax

[result, ifail] = g01fa(p, 'tail', tail)
[result, ifail] = nag_stat_inv_cdf_normal(p, 'tail', tail)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: tail was made optional (default 'L')

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.

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

Parameters

Compulsory Input Parameters

1:     p – double scalar
p, the probability from the standard Normal distribution as defined by tail.
Constraint: 0.0<p<1.0.

Optional Input Parameters

1:     tail – string (length ≥ 1)
Default: 'L'
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'.

Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
If on exit ifail0, then nag_stat_inv_cdf_normal (g01fa) returns 0.0.
   ifail=1
On entry,tail'L', 'U', 'S' or 'C'.
   ifail=2
On entry,p0.0,
orp1.0.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The accuracy is mainly limited by the machine precision.

Further Comments

None.

Example

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


fprintf('g01fa example results\n\n');

p    = [ 0.975;    0.025;        0.950;   0.050];
tail = {'Lower'; 'Upper'; 'Confidence'; 'Significance'};

fprintf('  Tail    probability    deviate\n');
for j = 1:numel(p);

  [x, ifail] = g01fa( ...
                      p(j) ,'tail', tail{j});

  fprintf('%4s%14.3f%14.4f\n', tail{j}(1), p(j), x);
end


g01fa example results

  Tail    probability    deviate
   L         0.975        1.9600
   U         0.025        1.9600
   C         0.950        1.9600
   S         0.050        1.9600

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–2015