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_inv_cdf_normal (g01fa)

Purpose

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

Syntax

[result, ifail] = g01fa(p, 'tail', tail)
[result, ifail] = nag_stat_inv_cdf_normal(p, 'tail', tail)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: tail now optional (default 'l')
.

Description

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

Parameters

Compulsory Input Parameters

1:     p – double scalar
p$p$, the probability from the standard Normal distribution as defined by tail.
Constraint: 0.0 < p < 1.0$0.0<{\mathbf{p}}<1.0$.

Optional Input Parameters

1:     tail – string (length ≥ 1)
Indicates which tail the supplied probability represents.
tail = 'L'${\mathbf{tail}}=\text{'L'}$
The lower probability, i.e., P(Xxp)$P\left(X\le {x}_{p}\right)$.
tail = 'U'${\mathbf{tail}}=\text{'U'}$
The upper probability, i.e., P(Xxp)$P\left(X\ge {x}_{p}\right)$.
tail = 'S'${\mathbf{tail}}=\text{'S'}$
The two tail (significance level) probability, i.e., P(X|xp|) + P(X|xp|)$P\left(X\ge |{x}_{p}|\right)+P\left(X\le -|{x}_{p}|\right)$.
tail = 'C'${\mathbf{tail}}=\text{'C'}$
The two tail (confidence interval) probability, i.e., P(X|xp|)P(X|xp|)$P\left(X\le |{x}_{p}|\right)-P\left(X\le -|{x}_{p}|\right)$.
Default: 'L'$\text{'L'}$
Constraint: tail = 'L'${\mathbf{tail}}=\text{'L'}$, 'U'$\text{'U'}$, 'S'$\text{'S'}$ or 'C'$\text{'C'}$.

None.

Output Parameters

1:     result – double scalar
The result of the function.
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:
If on exit ${\mathbf{ifail}}\ne {\mathbf{0}}$, then nag_stat_inv_cdf_normal (g01fa) returns 0.0$0.0$.
ifail = 1${\mathbf{ifail}}=1$
 On entry, tail ≠ 'L'${\mathbf{tail}}\ne \text{'L'}$, 'U'$\text{'U'}$, 'S'$\text{'S'}$ or 'C'$\text{'C'}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, p ≤ 0.0${\mathbf{p}}\le 0.0$, or p ≥ 1.0${\mathbf{p}}\ge 1.0$.

Accuracy

The accuracy is mainly limited by the machine precision.

None.

Example

```function nag_stat_inv_cdf_normal_example
p = 0.975;
[result, ifail] = nag_stat_inv_cdf_normal(p)
```
```

result =

1.9600

ifail =

0

```
```function g01fa_example
p = 0.975;
[result, ifail] = g01fa(p)
```
```

result =

1.9600

ifail =

0

```