﻿ g01fa Method
g01fa returns the deviate associated with the given probability of the standard Normal distribution.

# Syntax

C#
```public static double g01fa(
string tail,
double p,
out int ifail
)```
Visual Basic
```Public Shared Function g01fa ( _
tail As String, _
p As Double, _
<OutAttribute> ByRef ifail As Integer _
) As Double```
Visual C++
```public:
static double g01fa(
String^ tail,
double p,
[OutAttribute] int% ifail
)```
F#
```static member g01fa :
tail : string *
p : float *
ifail : int byref -> float
```

#### Parameters

tail
Type: System..::..String
On entry: indicates which tail the supplied probability represents.
${\mathbf{tail}}=\text{"L"}$
The lower probability, i.e., $P\left(X\le {x}_{p}\right)$.
${\mathbf{tail}}=\text{"U"}$
The upper probability, i.e., $P\left(X\ge {x}_{p}\right)$.
${\mathbf{tail}}=\text{"S"}$
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}}=\text{"C"}$
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}}=\text{"L"}$, $\text{"U"}$, $\text{"S"}$ or $\text{"C"}$.
p
Type: System..::..Double
On entry: $p$, the probability from the standard Normal distribution as defined by tail.
Constraint: $0.0<{\mathbf{p}}<1.0$.
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]).

#### Return Value

g01fa returns the deviate associated with the given probability of the standard Normal distribution.

# 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=sAs2Bs2,$
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 qCtDt,$
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 qEuFu+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$.

# 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

# Error Indicators and Warnings

Errors or warnings detected by the method:
If on exit ${\mathbf{ifail}}\ne {0}$, then g01fa returns $0.0$.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{tail}}\ne \text{"L"}$, $\text{"U"}$, $\text{"S"}$ or $\text{"C"}$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{p}}\le 0.0$, or ${\mathbf{p}}\ge 1.0$.
${\mathbf{ifail}}=-9000$
An error occured, see message report.

# Accuracy

The accuracy is mainly limited by the machine precision.

None.

None.

# Example

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

Example program (C#): g01fae.cs

Example program data: g01fae.d

Example program results: g01fae.r