g01fe returns the deviate associated with the given lower tail probability of the beta distribution.

# Syntax

C# |
---|

public static double g01fe( double p, double a, double b, double tol, out int ifail ) |

Visual Basic |
---|

Public Shared Function g01fe ( _ p As Double, _ a As Double, _ b As Double, _ tol As Double, _ <OutAttribute> ByRef ifail As Integer _ ) As Double |

Visual C++ |
---|

public: static double g01fe( double p, double a, double b, double tol, [OutAttribute] int% ifail ) |

F# |
---|

static member g01fe : p : float * a : float * b : float * tol : float * ifail : int byref -> float |

#### Parameters

- p
- Type: System..::..Double
*On entry*: $p$, the lower tail probability from the required beta distribution.*Constraint*: $0.0\le {\mathbf{p}}\le 1.0$.

- a
- Type: System..::..Double
*On entry*: $a$, the first parameter of the required beta distribution.*Constraint*: $0.0<{\mathbf{a}}\le {10}^{6}$.

- b
- Type: System..::..Double
*On entry*: $b$, the second parameter of the required beta distribution.*Constraint*: $0.0<{\mathbf{b}}\le {10}^{6}$.

- tol
- Type: System..::..Double

- 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

g01fe returns the deviate associated with the given lower tail probability of the beta distribution.

# Description

The deviate, ${\beta}_{p}$, associated with the lower tail probability, $p$, of the beta distribution with parameters $a$ and $b$ is defined as the solution to

The algorithm is a modified version of the Newton–Raphson method, following closely that of Cran et al. (1977).

$$P\left(B\le {\beta}_{p}:a,b\right)=p=\frac{\Gamma \left(a+b\right)}{\Gamma \left(a\right)\Gamma \left(b\right)}\underset{0}{\overset{{\beta}_{p}}{\int}}{B}^{a-1}{\left(1-B\right)}^{b-1}dB\text{, \hspace{1em}}0\le {\beta}_{p}\le 1\text{;}a,b>0\text{.}$$ |

An initial approximation, ${\beta}_{0}$, to ${\beta}_{p}$ is found (see Cran et al. (1977)), and the Newton–Raphson iteration

where $f\left(\beta \right)=P\left(B\le \beta :a,b\right)-p$ is used, with modifications to ensure that $\beta $ remains in the range $\left(0,1\right)$.

$${\beta}_{i}={\beta}_{i-1}-\frac{f\left({\beta}_{i-1}\right)}{{f}^{\prime}\left({\beta}_{i-1}\right)}\text{,}$$ |

# References

Cran G W, Martin K J and Thomas G E (1977) Algorithm AS 109. Inverse of the incomplete beta function ratio

*Appl. Statist.***26**111–114Hastings N A J and Peacock J B (1975)

*Statistical Distributions*Butterworth# Error Indicators and Warnings

**Note:**g01fe may return useful information for one or more of the following detected errors or warnings.

Errors or warnings detected by the method:

- ${\mathbf{ifail}}=1$
On entry, ${\mathbf{p}}<0.0$, or ${\mathbf{p}}>1.0$.

- ${\mathbf{ifail}}=2$
On entry, ${\mathbf{a}}\le 0.0$, or ${\mathbf{a}}>{10}^{6}$, or ${\mathbf{b}}\le 0.0$, or ${\mathbf{b}}>{10}^{6}$.

- ${\mathbf{ifail}}=3$
- There is doubt concerning the accuracy of the computed result. $100$ iterations of the Newton–Raphson method have been performed without satisfying the accuracy criterion (see [Accuracy]). The result should be a reasonable approximation of the solution.

- ${\mathbf{ifail}}=4$
- Requested accuracy not achieved when calculating beta probability. The result should be a reasonable approximation to the correct solution. You should try setting tol larger.

# Accuracy

The required precision, given by tol, should be achieved in most circumstances.

# Parallelism and Performance

None.

# Further Comments

# Example

This example reads lower tail probabilities for several beta distributions and calculates and prints the corresponding deviates until the end of data is reached.

Example program (C#): g01fee.cs