NAG Library Routine Document
g01daf
(normal_scores_exact)
1
Purpose
g01daf computes a 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 .
2
Specification
Fortran Interface
Integer, Intent (In) | :: |
n,
iw | Integer, Intent (Inout) | :: |
ifail | Real (Kind=nag_wp), Intent (In) | :: |
etol | Real (Kind=nag_wp), Intent (Out) | :: |
pp(n),
errest,
work(iw) |
|
C Header Interface
#include nagmk26.h
void |
g01daf_ (
const Integer *n,
double pp[],
const double *etol,
double *errest,
double work[],
const Integer *iw,
Integer *ifail) |
|
3
Description
If a sample of
observations from any distribution (which may be denoted by
), is sorted into ascending order, the
th smallest value in the sample is often referred to as the
th ‘
order statistic’, sometimes denoted by
(see
Kendall and Stuart (1969)).
The order statistics therefore have the property
(If
,
is the sample median.)
For samples originating from a known distribution, the distribution of each order statistic in a sample of given size may be determined. In particular, the expected values of the order statistics may be found by integration. If the sample arises from a Normal distribution, the expected values of the order statistics are referred to as the ‘Normal scores’. The Normal scores provide a set of reference values against which the order statistics of an actual data sample of the same size may be compared, to provide an indication of Normality for the sample.
Normal scores have other applications; for instance, they are sometimes used as alternatives to ranks in nonparametric testing procedures.
g01daf computes the
th Normal score for a given sample size
as
where
and
denotes the complete beta function.
The routine attempts to evaluate the scores so that the estimated error in each score is less than the value
etol specified by you. All integrations are performed in parallel and arranged so as to give good speed and reasonable accuracy.
4
References
Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin
5
Arguments
- 1: – IntegerInput
-
On entry: , the size of the set.
Constraint:
.
- 2: – Real (Kind=nag_wp) arrayOutput
-
On exit: the Normal scores.
contains the value , for .
- 3: – Real (Kind=nag_wp)Input
-
On entry: the maximum value for the estimated absolute error in the computed scores.
Constraint:
.
- 4: – Real (Kind=nag_wp)Output
-
On exit: a computed estimate of the maximum error in the computed scores (see
Section 7).
- 5: – Real (Kind=nag_wp) arrayWorkspace
- 6: – IntegerInput
-
On entry: the dimension of the array
work as declared in the (sub)program from which
g01daf is called.
Constraints:
- if , ;
- otherwise .
- 7: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
The routine was unable to estimate the scores with estimated
error less than
etol. The best result obtained is returned together with the associated value of
errest.
-
On entry,
iw is too small. Minimum size required:
.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
Errors are introduced by evaluation of the functions
and errors in the numerical integration process. Errors are also introduced by the approximation of the true infinite range of integration by a finite range
but
and
are chosen so that this effect is of lower order than that of the other two factors. In order to estimate the maximum error the functions
are also integrated over the range
.
g01daf returns the estimated maximum error as
8
Parallelism and Performance
g01daf is not threaded in any implementation.
The time taken by
g01daf depends on
etol and
n. For a given value of
etol the timing varies approximately linearly with
n.
10
Example
The program below generates the Normal scores for samples of size , , , and prints the scores and the computed error estimates.
10.1
Program Text
Program Text (g01dafe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (g01dafe.r)
This shows a Q-Q plot for a randomly generated set of data. The normal scores have been calculated using
g01daf and the sample quantiles obtained by sorting the observed data using
m01caf. A reference line at
is also shown.