PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_stat_normal_scores_approx (g01db)
Purpose
nag_stat_normal_scores_approx (g01db) calculates an approximation to the set of Normal Scores, i.e., the expected values of an ordered set of independent observations from a Normal distribution with mean and standard deviation .
Syntax
[
pp,
ifail] = nag_stat_normal_scores_approx(
n)
Description
nag_stat_normal_scores_approx (g01db) is an adaptation of the Applied Statistics Algorithm AS
, see
Royston (1982). If you are particularly concerned with the accuracy with which
nag_stat_normal_scores_approx (g01db) computes the expected values of the order statistics (see
Accuracy), then
nag_stat_normal_scores_exact (g01da) which is more accurate should be used instead at a cost of increased storage and computing time.
Let
be the order statistics from a random sample of size
from the standard Normal distribution. Defining
and
where
is the expected value of
, the current function approximates the Normal upper tail area corresponding to
as,
for
, and
. Estimates of
,
,
,
and
are obtained. A small correction
to
is necessary when
and
.
The approximation to
is thus given by
Values of the inverse Normal probability integral
are obtained from
nag_stat_inv_cdf_normal (g01fa).
References
Royston J P (1982) Algorithm AS 177: expected normal order statistics (exact and approximate) Appl. Statist. 31 161–165
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the size of the sample.
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
The Normal scores.
contains the value , for .
- 2:
– 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:
-
-
-
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
For
, the maximum error is
, but
nag_stat_normal_scores_approx (g01db) is usually accurate to
or
decimal places. For
up to
, comparison with the exact scores calculated by
nag_stat_normal_scores_exact (g01da) shows that the maximum error is
.
Further Comments
The time taken by nag_stat_normal_scores_approx (g01db) is proportional to .
Example
A program to calculate the expected values of the order statistics for a sample of size .
Open in the MATLAB editor:
g01db_example
function g01db_example
fprintf('g01db example results\n\n');
n = int64(10);
[pp, ifail] = g01db(n);
fprintf('Sample size = %5d\n', n);
fprintf('Normal scores\n');
fprintf(' %10.4f%10.4f%10.4f%10.4f%10.4f\n',pp(1:n));
g01db_plot;
function g01db_plot
seed = [int64(6324213)];
genid = int64(3);
subid = int64(0);
[state, ifail] = g05kf( ...
genid, subid, seed);
n = int64(50);
df = int64(5);
[state, x, ifail] = g05sn( ...
n, df, state);
m1 = int64(1);
[x, ifail] = m01ca(x, m1, 'Ascending');
[pp, ifail] = g01db(n);
fig1 = figure;
hold on
plot(pp,x,'+r',[-2.25 2.25],[-2.25 2.25],'black');
axis([-2.5 2.5 -3 3]);
xlabel('Normal scores');
ylabel('sample Quantiles');
title({'Q-Q plot for a random set of data','using exact normal scores'});
hold off;
g01db example results
Sample size = 10
Normal scores
-1.5388 -1.0014 -0.6561 -0.3757 -0.1227
0.1227 0.3757 0.6561 1.0014 1.5388
This shows a Q-Q plot for a randomly generated set of data. The normal scores have been calculated using
nag_stat_normal_scores_approx (g01db) and the sample quantiles obtained by sorting the observed data using
nag_sort_realvec_sort (m01ca). A reference line at
is also shown.
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015