NAG Library Function Document
nag_normal_scores_exact (g01dac)
1 Purpose
nag_normal_scores_exact (g01dac) computes a set of Normal scores, i.e., the expected values of an ordered set of independent observations from a Normal distribution with mean $0.0$ and standard deviation $1.0$.
2 Specification
#include <nag.h> 
#include <nagg01.h> 
void 
nag_normal_scores_exact (Integer n,
double pp[],
double etol,
double *errest,
NagError *fail) 

3 Description
If a sample of
$n$ observations from any distribution (which may be denoted by
${x}_{1},{x}_{2},\dots ,{x}_{n}$), is sorted into ascending order, the
$r$th smallest value in the sample is often referred to as the
$r$th ‘
order statistic’, sometimes denoted by
${x}_{\left(r\right)}$ (see
Kendall and Stuart (1969)).
The order statistics therefore have the property
(If
$n=2r+1$,
${x}_{r+1}$ 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
.
A plot of the data against the scores gives a normal probability plot.
Normal scores have other applications; for instance, they are sometimes used as alternatives to ranks in nonparametric testing procedures.
nag_normal_scores_exact (g01dac) computes the
$r$th Normal score for a given sample size
$n$ as
where
and
$\beta $ denotes the complete beta function.
The function 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:
$\mathbf{n}$ – IntegerInput

On entry: $n$, the size of the set.
Constraint:
${\mathbf{n}}>0$.
 2:
$\mathbf{pp}\left[{\mathbf{n}}\right]$ – doubleOutput

On exit: the Normal scores.
${\mathbf{pp}}\left[\mathit{i}1\right]$ contains the value $E\left({x}_{\left(\mathit{i}\right)}\right)$, for $\mathit{i}=1,2,\dots ,n$.
 3:
$\mathbf{etol}$ – doubleInput

On entry: the maximum value for the estimated absolute error in the computed scores.
Constraint:
${\mathbf{etol}}>0.0$.
 4:
$\mathbf{errest}$ – double *Output

On exit: a computed estimate of the maximum error in the computed scores (see
Section 7).
 5:
$\mathbf{fail}$ – NagError *Input/Output

The NAG error argument (see
Section 2.7 in How to Use the NAG Library and its Documentation).
6 Error Indicators and Warnings
 NE_ALLOC_FAIL

Dynamic memory allocation failed.
See
Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
 NE_BAD_PARAM

On entry, argument $\u2329\mathit{\text{value}}\u232a$ had an illegal value.
 NE_ERROR_ESTIMATE

The function was unable to estimate the scores with estimated error less than
etol.
 NE_INT

On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}>0$.
 NE_INTERNAL_ERROR

An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
An unexpected error has been triggered by this function. Please contact
NAG.
See
Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
 NE_NO_LICENCE

Your licence key may have expired or may not have been installed correctly.
See
Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
 NE_REAL

On entry, ${\mathbf{etol}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{etol}}>0.0$.
7 Accuracy
Errors are introduced by evaluation of the functions
$d{G}_{r}$ 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
$\left[a,b\right]$ but
$a$ and
$b$ 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
$d{G}_{r}$ are also integrated over the range
$\left[a,b\right]$. nag_normal_scores_exact (g01dac) returns the estimated maximum error as
8 Parallelism and Performance
nag_normal_scores_exact (g01dac) is not threaded in any implementation.
The time taken by nag_normal_scores_exact (g01dac) 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 $5$, $10$, $15$, and prints the scores and the computed error estimates.
10.1 Program Text
Program Text (g01dace.c)
10.2 Program Data
None.
10.3 Program Results
Program Results (g01dace.r)
This shows a QQ plot for a randomly generated set of data. The normal scores have been calculated using nag_normal_scores_exact (g01dac) and the sample quantiles obtained by sorting the observed data using
nag_double_sort (m01cac). A reference line at
$y=x$ is also shown.