G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01DBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G01DBF 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 $0.0$ and standard deviation $1.0$.

## 2  Specification

 SUBROUTINE G01DBF ( N, PP, IFAIL)
 INTEGER N, IFAIL REAL (KIND=nag_wp) PP(N)

## 3  Description

G01DBF is an adaptation of the Applied Statistics Algorithm AS $177.3$, see Royston (1982). If you are particularly concerned with the accuracy with which G01DBF computes the expected values of the order statistics (see Section 7), then G01DAF which is more accurate should be used instead at a cost of increased storage and computing time.
Let ${x}_{\left(1\right)},{x}_{\left(2\right)},\dots ,{x}_{\left(n\right)}$ be the order statistics from a random sample of size $n$ from the standard Normal distribution. Defining
 $Pr,n=Φ-Exr$
and
 $Qr,n=r-ε n+γ , r= 1,2,…,n,$
where $E\left({x}_{\left(r\right)}\right)$ is the expected value of ${x}_{\left(r\right)}$, the current routine approximates the Normal upper tail area corresponding to $E\left({x}_{\left(r\right)}\right)$ as,
 $P~r,n=Qr,n+δ1nQr,nλ+δ2nQr,n 2λ-Cr,n.$
for $\mathit{r}=1,2,3$, and $r\ge 4$. Estimates of $\epsilon$, $\gamma$, ${\delta }_{1}$, ${\delta }_{2}$ and $\lambda$ are obtained. A small correction ${C}_{r,n}$ to ${\stackrel{~}{P}}_{r,n}$ is necessary when $r\le 7$ and $n\le 20$.
The approximation to $E\left({X}_{\left(r\right)}\right)$ is thus given by
 $E x r = - Φ-1 P ~ r , n , r =1,2,…,n .$
Values of the inverse Normal probability integral ${\Phi }^{-1}$ are obtained from G01FAF.

## 4  References

Royston J P (1982) Algorithm AS 177: expected normal order statistics (exact and approximate) Appl. Statist. 31 161–165

## 5  Parameters

1:     N – INTEGERInput
On entry: $n$, the size of the sample.
Constraint: ${\mathbf{N}}\ge 1$.
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:     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$.

## 7  Accuracy

For $n\le 2000$, the maximum error is $0.0001$, but G01DBF is usually accurate to $5$ or $6$ decimal places. For $n$ up to $5000$, comparison with the exact scores calculated by G01DAF shows that the maximum error is $0.001$.

The time taken by G01DBF is proportional to $n$.

## 9  Example

A program to calculate the expected values of the order statistics for a sample of size $10$.

### 9.1  Program Text

Program Text (g01dbfe.f90)

### 9.2  Program Data

Program Data (g01dbfe.d)

### 9.3  Program Results

Program Results (g01dbfe.r)