PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_stat_prob_normal_vector (g01sa)
Purpose
nag_stat_prob_normal_vector (g01sa) returns a number of one or two tail probabilities for the Normal distribution.
Syntax
[
p,
ivalid,
ifail] = g01sa(
tail,
x,
xmu,
xstd, 'ltail',
ltail, 'lx',
lx, 'lxmu',
lxmu, 'lxstd',
lxstd)
[
p,
ivalid,
ifail] = nag_stat_prob_normal_vector(
tail,
x,
xmu,
xstd, 'ltail',
ltail, 'lx',
lx, 'lxmu',
lxmu, 'lxstd',
lxstd)
Description
The lower tail probability for the Normal distribution,
is defined by:
where
The relationship
is used, where erfc is the complementary error function, and is computed using
nag_specfun_erfc_real (s15ad).
When the two tail confidence probability is required the relationship
is used, where erf is the error function, and is computed using
nag_specfun_erf_real (s15ae).
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
Parameters
Compulsory Input Parameters
- 1:
– cell array of strings
-
Indicates which tail the returned probabilities should represent. Letting
denote a variate from a standard Normal distribution, and
, then for
, for
:
- The lower tail probability is returned, i.e., .
- The upper tail probability is returned, i.e., .
- The two tail (confidence interval) probability is returned, i.e., .
- The two tail (significance level) probability is returned, i.e., .
Constraint:
, , or , for .
- 2:
– double array
-
, the Normal variate values with , .
- 3:
– double array
-
, the means with , .
- 4:
– double array
-
, the standard deviations with , .
Constraint:
, for .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
tail.
The length of the array
tail.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
The length of the array
x.
Constraint:
.
- 3:
– int64int32nag_int scalar
-
Default:
the dimension of the array
xmu.
The length of the array
xmu.
Constraint:
.
- 4:
– int64int32nag_int scalar
-
Default:
the dimension of the array
xstd.
The length of the array
xstd.
Constraint:
.
Output Parameters
- 1:
– double array
-
The dimension of the array
p will be
, the probabilities for the Normal distribution.
- 2:
– int64int32nag_int array
-
The dimension of the array
ivalid will be
indicates any errors with the input arguments, with
- No error.
-
On entry, | invalid value supplied in tail when calculating . |
-
- 3:
– int64int32nag_int scalar
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
-
On entry, at least one value of
tail or
xstd was invalid.
Check
ivalid for more information.
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Further Comments
None.
Example
Four values of
tail,
x,
xmu and
xstd are input and the probabilities calculated and printed.
Open in the MATLAB editor:
g01sa_example
function g01sa_example
fprintf('g01sa example results\n\n');
x = [1.96; 1.96; 1.96; 1.96];
xmu = [0; 0; 0; 0];
xstd = [1; 1; 1; 1];
tail = {'L'; 'U'; 'C'; 'S'};
[prob, ivalid, ifail] = g01sa( ...
tail, x, xmu, xstd);
fprintf('tail x xmu xstd probability\n');
lx = numel(x);
lxmu = numel(xmu);
lxstd = numel(xstd);
ltail = numel(tail);
len = max ([lx, lxmu, lxstd, ltail]);
for i=0:len-1
fprintf(' %c %8.2f %8.2f %8.2f %8.3f\n', tail{mod(i,ltail)+1}, ...
x(mod(i,lx)+1), xmu(mod(i,lxmu)+1), xstd(mod(i,lxstd)+1), prob(i+1));
end
g01sa example results
tail x xmu xstd probability
L 1.96 0.00 1.00 0.975
U 1.96 0.00 1.00 0.025
C 1.96 0.00 1.00 0.950
S 1.96 0.00 1.00 0.050
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015