NAG Library Routine Document
G01DAF
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 $0.0$ and standard deviation $1.0$.
2 Specification
INTEGER 
N, IW, IFAIL 
REAL (KIND=nag_wp) 
PP(N), ETOL, ERREST, WORK(IW) 

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
(see
G01AHF).
Normal scores have other applications; for instance, they are sometimes used as alternatives to ranks in nonparametric testing procedures.
G01DAF computes the
$r$th Normal score for a given sample size
$n$ as
where
and
$\beta $ 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 Parameters
 1: N – INTEGERInput
On entry: $n$, the size of the set.
Constraint:
${\mathbf{N}}>0$.
 2: PP(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the Normal scores.
${\mathbf{PP}}\left(\mathit{i}\right)$ contains the value $E\left({x}_{\left(\mathit{i}\right)}\right)$, for $\mathit{i}=1,2,\dots ,n$.
 3: ETOL – REAL (KIND=nag_wp)Input
On entry: the maximum value for the estimated absolute error in the computed scores.
Constraint:
${\mathbf{ETOL}}>0.0$.
 4: ERREST – REAL (KIND=nag_wp)Output
On exit: a computed estimate of the maximum error in the computed scores (see
Section 7).
 5: WORK(IW) – REAL (KIND=nag_wp) arrayWorkspace
 6: IW – INTEGERInput
On entry: the dimension of the array
WORK as declared in the (sub)program from which G01DAF is called.
Constraints:
 if ${\mathbf{N}}\text{must be even}$, ${\mathbf{IW}}\ge 3\times {\mathbf{N}}/2$;
 otherwise ${\mathbf{IW}}\ge 3\times \left({\mathbf{N}}1\right)/2$.
 7: IFAIL – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ or}1$. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
$1\text{ or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit:
${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
 ${\mathbf{IFAIL}}=1$

On entry,  ${\mathbf{N}}<1$. 
 ${\mathbf{IFAIL}}=2$
On entry,  ${\mathbf{ETOL}}\le 0.0$. 
 ${\mathbf{IFAIL}}=3$
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.
 ${\mathbf{IFAIL}}=4$
On entry,  if N is even, ${\mathbf{IW}}<3\times {\mathbf{N}}/2$; 
or  if N is odd, ${\mathbf{IW}}<3\times \left({\mathbf{N}}1\right)/2$. 
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]$. G01DAF returns the estimated maximum error as
The time taken by G01DAF depends on
ETOL and
N. For a given value of
ETOL the timing varies approximately linearly with
N.
9 Example
The program below generates the Normal scores for samples of size $5$, $10$, $15$, and prints the scores and the computed error estimates.
9.1 Program Text
Program Text (g01dafe.f90)
9.2 Program Data
Program Data (g01dafe.d)
9.3 Program Results
Program Results (g01dafe.r)