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_prob_normal (g01ea)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_prob_normal (g01ea) returns a one or two tail probability for the standard Normal distribution.

Syntax

[result, ifail] = g01ea(x, 'tail', tail)
[result, ifail] = nag_stat_prob_normal(x, '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 lower tail probability for the standard Normal distribution, PXx is defined by:
PXx=-xZXdX,  
where
ZX=12π e-X2/2, -<X< .  
The relationship
PXx=12erfc-x2  
is used, where erfc is the complementary error function, and is computed using nag_specfun_erfc_real (s15ad). For the upper tail probability the relationship PXx=PX-x is used and for the two tail significance level probability twice the probability obtained from the absolute value of x is returned.
When the two tail confidence probability is required the relationship
PXx-PX-x=erfx2 ,  
is used, where erf is the error function, and is computed using nag_specfun_erf_real (s15ae).

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

Parameters

Compulsory Input Parameters

1:     x – double scalar
x, the value of the standard Normal variate.

Optional Input Parameters

1:     tail – string (length ≥ 1)
Default: 'L'
Indicates which tail the returned probability should represent.
tail='L'
The lower tail probability is returned, i.e., PXx.
tail='U'
The upper tail probability is returned, i.e., PXx.
tail='S'
The two tail (significance level) probability is returned, i.e., PXx+PX-x.
tail='C'
The two tail (confidence interval) probability is returned, i.e., PXx-PX-x.
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 ifail0, then nag_stat_prob_normal (g01ea) returns 0.0.
   ifail=1
On entry,tail'L', 'U', 'S' or 'C'.
   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

Accuracy is limited by machine precision. For detailed error analysis see nag_specfun_erfc_real (s15ad) and nag_specfun_erf_real (s15ae).

Further Comments

None.

Example

Four values of tail and x are input and the probabilities calculated and printed.
function g01ea_example


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

% Probability for Normal distribution
x     = 1.96;
tail = {'Lower'; 'Upper'; 'Confidence'; 'Significance'};

fprintf('  Tail    x      probability\n');
for j = 1:size(tail,1);

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

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


g01ea example results

  Tail    x      probability
   L    1.96      0.9750
   U    1.96      0.0250
   C    1.96      0.9500
   S    1.96      0.0500

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