Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_normal_scores_approx (g01db)

## Purpose

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

## Syntax

[pp, ifail] = g01db(n)
[pp, ifail] = nag_stat_normal_scores_approx(n)

## Description

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

## References

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

## Parameters

### Compulsory Input Parameters

1:     n – int64int32nag_int scalar
n$n$, the size of the sample.
Constraint: n1${\mathbf{n}}\ge 1$.

None.

None.

### Output Parameters

1:     pp(n) – double array
The Normal scores. pp(i)${\mathbf{pp}}\left(\mathit{i}\right)$ contains the value E(x(i))$E\left({x}_{\left(\mathit{i}\right)}\right)$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 1${\mathbf{n}}<1$.

## Accuracy

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

The time taken by nag_stat_normal_scores_approx (g01db) is proportional to n$n$.

## Example

```function nag_stat_normal_scores_approx_example
n = int64(10);
[pp, ifail] = nag_stat_normal_scores_approx(n)
```
```

pp =

-1.5388
-1.0014
-0.6561
-0.3757
-0.1227
0.1227
0.3757
0.6561
1.0014
1.5388

ifail =

0

```
```function g01db_example
n = int64(10);
[pp, ifail] = g01db(n)
```
```

pp =

-1.5388
-1.0014
-0.6561
-0.3757
-0.1227
0.1227
0.3757
0.6561
1.0014
1.5388

ifail =

0

```