NAG Library Routine Document

g01dbf (normal_scores_approx)

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

Fortran Interface
Subroutine g01dbf ( n, pp, ifail)
Integer, Intent (In):: n
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (Out):: pp(n)
C Header Interface
#include <nagmk26.h>
void  g01dbf_ (const Integer *n, double pp[], Integer *ifail)

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 x1,x2,,xn 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 Exr is the expected value of xr, the current routine approximates the Normal upper tail area corresponding to Exr as,
P~r,n=Qr,n+δ1nQr,nλ+δ2nQr,n 2λ-Cr,n.  
for r=1,2,3, and r4. Estimates of ε, γ, δ1, δ2 and λ are obtained. A small correction Cr,n to P~r,n is necessary when r7 and n20.
The approximation to EXr is thus given by
E x r = - Φ-1 P ~ r , n , r =1,2,,n .  
Values of the inverse Normal probability integral Φ-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
Arguments

1:     n – IntegerInput
On entry: n, the size of the sample.
Constraint: n1.
2:     ppn – Real (Kind=nag_wp) arrayOutput
On exit: the Normal scores. ppi contains the value Exi, for i=1,2,,n.
3:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 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 argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, n=value.
Constraint: n1.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

For n2000, 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.

8
Parallelism and Performance

g01dbf is not threaded in any implementation.

9
Further Comments

The time taken by g01dbf is proportional to n.

10
Example

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

10.1
Program Text

Program Text (g01dbfe.f90)

10.2
Program Data

None.

10.3
Program Results

Program Results (g01dbfe.r)

This shows a Q-Q plot for a randomly generated set of data. The normal scores have been calculated using g01dbf and the sample quantiles obtained by sorting the observed data using m01caf. A reference line at y=x is also shown.
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −3 −2 −1 0 1 2 3 −2.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 2.5 Sample Quantiles Normal Scores Example Program Q-Q Plot for a Random Set of Data Using Approximate Normal Scores gnuplot_plot_1 gnuplot_plot_2