g01 Chapter Contents
g01 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_deviates_normal (g01fac)

## 1  Purpose

nag_deviates_normal (g01fac) returns the deviate associated with the given probability of the standard Normal distribution.

## 2  Specification

 #include #include
 double nag_deviates_normal (Nag_TailProbability tail, double p, NagError *fail)

## 3  Description

The deviate, ${x}_{p}$ associated with the lower tail probability, $p$, for the standard Normal distribution is defined as the solution to
 $PX≤xp=p=∫-∞xpZXdX,$
where
 $ZX=12πe-X2/2, -∞
The method used is an extension of that of Wichura (1988). $p$ is first replaced by $q=p-0.5$.
(a) If $\left|q\right|\le 0.3$, ${x}_{p}$ is computed by a rational Chebyshev approximation
 $xp=sAs2 Bs2 ,$
where $s=\sqrt{2\pi }q$ and $A$, $B$ are polynomials of degree $7$.
(b) If $0.3<\left|q\right|\le 0.42$, ${x}_{p}$ is computed by a rational Chebyshev approximation
 $xp=sign⁡q Ct Dt ,$
where $t=\left|q\right|-0.3$ and $C$, $D$ are polynomials of degree $5$.
(c) If $\left|q\right|>0.42$, ${x}_{p}$ is computed as
 $xp=sign⁡q Eu Fu +u ,$
where $u=\sqrt{-2×\mathrm{log}\left(\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(p,1-p\right)\right)}$ and $E$, $F$ are polynomials of degree $6$.
For the upper tail probability $-{x}_{p}$ is returned, while for the two tail probabilities the value ${x}_{{p}^{*}}$ is returned, where ${p}^{*}$ is the required tail probability computed from the input value of $p$.

## 4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Wichura (1988) Algorithm AS 241: the percentage points of the Normal distribution Appl. Statist. 37 477–484

## 5  Arguments

1:     tailNag_TailProbabilityInput
On entry: indicates which tail the supplied probability represents.
${\mathbf{tail}}=\mathrm{Nag_LowerTail}$
The lower probability, i.e., $P\left(X\le {x}_{p}\right)$.
${\mathbf{tail}}=\mathrm{Nag_UpperTail}$
The upper probability, i.e., $P\left(X\ge {x}_{p}\right)$.
${\mathbf{tail}}=\mathrm{Nag_TwoTailSignif}$
The two tail (significance level) probability, i.e., $P\left(X\ge \left|{x}_{p}\right|\right)+P\left(X\le -\left|{x}_{p}\right|\right)$.
${\mathbf{tail}}=\mathrm{Nag_TwoTailConfid}$
The two tail (confidence interval) probability, i.e., $P\left(X\le \left|{x}_{p}\right|\right)-P\left(X\le -\left|{x}_{p}\right|\right)$.
Constraint: ${\mathbf{tail}}=\mathrm{Nag_LowerTail}$, $\mathrm{Nag_UpperTail}$, $\mathrm{Nag_TwoTailSignif}$ or $\mathrm{Nag_TwoTailConfid}$.
2:     pdoubleInput
On entry: $p$, the probability from the standard Normal distribution as defined by tail.
Constraint: $0.0<{\mathbf{p}}<1.0$.
3:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

If on exit NE_NOERROR, then nag_deviates_normal (g01fac) returns $0.0$.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL_ARG_GE
On entry, ${\mathbf{p}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{p}}<1.0$.
NE_REAL_ARG_LE
On entry, ${\mathbf{p}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{p}}>0.0$.

## 7  Accuracy

The accuracy is mainly limited by the machine precision.

None.

## 9  Example

Four values of tail and p are input and the deviates calculated and printed.

### 9.1  Program Text

Program Text (g01face.c)

### 9.2  Program Data

Program Data (g01face.d)

### 9.3  Program Results

Program Results (g01face.r)