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_vector (g01ta)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_inv_cdf_normal_vector (g01ta) returns a number of deviates associated with given probabilities of the Normal distribution.

Syntax

[x, ivalid, ifail] = g01ta(tail, p, xmu, xstd, 'ltail', ltail, 'lp', lp, 'lxmu', lxmu, 'lxstd', lxstd)
[x, ivalid, ifail] = nag_stat_inv_cdf_normal_vector(tail, p, xmu, xstd, 'ltail', ltail, 'lp', lp, 'lxmu', lxmu, 'lxstd', lxstd)

Description

The deviate, xpi associated with the lower tail probability, pi, for the Normal distribution is defined as the solution to
PXixpi=pi=-xpiZiXidXi,  
where
ZiXi=12πσi2e-Xi-μi2/2σi2, ​-<Xi< .  
The method used is an extension of that of Wichura (1988). pi is first replaced by qi=pi-0.5.
(a) If qi0.3, zi is computed by a rational Chebyshev approximation
zi=siAisi2 Bisi2 ,  
where si=2πqi and Ai, Bi are polynomials of degree 7.
(b) If 0.3<qi0.42, zi is computed by a rational Chebyshev approximation
zi=signqi Citi Diti ,  
where ti=qi-0.3 and Ci, Di are polynomials of degree 5.
(c) If qi>0.42, zi is computed as
zi=signqi Eiui Fiui +ui ,  
where ui = -2 × log minpi,1-pi  and Ei, Fi are polynomials of degree 6.
xpi is then calculated from zi, using the relationsship zpi = xi - μi σi .
For the upper tail probability -xpi is returned, while for the two tail probabilities the value xipi* is returned, where pi* is the required tail probability computed from the input value of pi.
The input arrays to this function are designed to allow maximum flexibility in the supply of vector arguments by re-using elements of any arrays that are shorter than the total number of evaluations required. See Vectorized Routines in the G01 Chapter Introduction for further information.

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:     tailltail – cell array of strings
Indicates which tail the supplied probabilities represent. Letting Z denote a variate from a standard Normal distribution, and zi = xpi - μi σi , then for j= i-1 mod ltail +1 , for i=1,2,,maxltail,lp,lxmu,lxstd:
tailj='L'
The lower tail probability, i.e., pi=PZzi.
tailj='U'
The upper tail probability, i.e., pi=PZzi.
tailj='C'
The two tail (confidence interval) probability, i.e., pi=PZzi-PZ-zi.
tailj='S'
The two tail (significance level) probability, i.e., pi=PZzi+PZ-zi.
Constraint: tailj='L', 'U', 'C' or 'S', for j=1,2,,ltail.
2:     plp – double array
pi, the probabilities for the Normal distribution as defined by tail with pi=pj, j=i-1 mod lp+1.
Constraint: 0.0<pj<1.0, for j=1,2,,lp.
3:     xmulxmu – double array
μi, the means with μi=xmuj, j=i-1 mod lxmu+1.
4:     xstdlxstd – double array
σi, the standard deviations with σi=xstdj, j=i-1 mod lxstd+1.
Constraint: xstdj>0.0, for j=1,2,,lxstd.

Optional Input Parameters

1:     ltail int64int32nag_int scalar
Default: the dimension of the array tail.
The length of the array tail.
Constraint: ltail>0.
2:     lp int64int32nag_int scalar
Default: the dimension of the array p.
The length of the array p.
Constraint: lp>0.
3:     lxmu int64int32nag_int scalar
Default: the dimension of the array xmu.
The length of the array xmu.
Constraint: lxmu>0.
4:     lxstd int64int32nag_int scalar
Default: the dimension of the array xstd.
The length of the array xstd.
Constraint: lxstd>0.

Output Parameters

1:     x: – double array
The dimension of the array x will be maxltail,lxmu,lxstd,lp
xpi, the deviates for the Normal distribution.
2:     ivalid: int64int32nag_int array
The dimension of the array ivalid will be maxltail,lxmu,lxstd,lp
ivalidi indicates any errors with the input arguments, with
ivalidi=0
No error.
ivalidi=1
On entry,invalid value supplied in tail when calculating xpi.
ivalidi=2
On entry,pi0.0,
orpi1.0.
ivalidi=3
On entry,σi0.0.
3:     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:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W  ifail=1
On entry, at least one value of tail, xstd or p was invalid.
Check ivalid for more information.
   ifail=2
Constraint: ltail>0.
   ifail=3
Constraint: lp>0.
   ifail=4
Constraint: lxmu>0.
   ifail=5
Constraint: lxstd>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

This example reads vectors of values for μi, σi and pi and prints the corresponding deviates.
function g01ta_example


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

p    = [0.9750; 0.0250; 0.9500; 0.0500];
xmu  = [0; 0; 0; 0];
xstd = [1; 1; 1; 1];
tail = {'L'; 'U'; 'C'; 'S'};

[dev, ivalid, ifail] = g01ta( ...
                              tail, p, xmu, xstd);

fprintf('tail    p              xmu      xstd      deviate\n');
lp    = numel(p);
lxmu  = numel(xmu);
lxstd = numel(xstd);
ltail = numel(tail);
len   = max ([lp, lxmu, lxstd, ltail]);
for i=0:len-1
  fprintf(' %c%11.3f%16.4f%8.3f%13.6f\n', tail{mod(i,ltail)+1}, ...
          p(mod(i,lp)+1), xmu(mod(i,lxmu)+1), xstd(mod(i,lxstd)+1), dev(i+1));
end


g01ta example results

tail    p              xmu      xstd      deviate
 L      0.975          0.0000   1.000     1.959964
 U      0.025          0.0000   1.000     1.959964
 C      0.950          0.0000   1.000     1.959964
 S      0.050          0.0000   1.000     1.959964

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