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

# Syntax

C#
```public static void g01db(
int n,
double[] pp,
out int ifail
)```
Visual Basic
```Public Shared Sub g01db ( _
n As Integer, _
pp As Double(), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g01db(
int n,
array<double>^ pp,
[OutAttribute] int% ifail
)```
F#
```static member g01db :
n : int *
pp : float[] *
ifail : int byref -> unit
```

#### Parameters

n
Type: System..::..Int32
On entry: $n$, the size of the sample.
Constraint: ${\mathbf{n}}\ge 1$.
pp
Type: array<System..::..Double>[]()[][]
An array of size [n]
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$.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

g01db is an adaptation of the Applied Statistics Algorithm AS $177.3$, see Royston (1982). If you are particularly concerned with the accuracy with which g01db computes the expected values of the order statistics (see [Accuracy]), then g01da 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 method approximates the Normal upper tail area corresponding to $E\left({x}_{\left(r\right)}\right)$ as,
 $P~r,n=Qr,n+δ1nQr,nλ+δ2nQr,n2λ-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
 $Exr=-Φ-1P~r,n, r=1,2,…,n.$
Values of the inverse Normal probability integral ${\Phi }^{-1}$ are obtained from g01fa.

# References

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

# Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}<1$.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

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

# Parallelism and Performance

None.

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

# Example

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

Example program (C#): g01dbe.cs

Example program data: g01dbe.d

Example program results: g01dbe.r