﻿ g01ge Method
g01ge returns the probability associated with the lower tail of the noncentral beta distribution.

# Syntax

C#
```public static double g01ge(
double x,
double a,
double b,
double rlamda,
double tol,
int maxit,
out int ifail
)```
Visual Basic
```Public Shared Function g01ge ( _
x As Double, _
a As Double, _
b As Double, _
rlamda As Double, _
tol As Double, _
maxit As Integer, _
<OutAttribute> ByRef ifail As Integer _
) As Double```
Visual C++
```public:
static double g01ge(
double x,
double a,
double b,
double rlamda,
double tol,
int maxit,
[OutAttribute] int% ifail
)```
F#
```static member g01ge :
x : float *
a : float *
b : float *
rlamda : float *
tol : float *
maxit : int *
ifail : int byref -> float
```

#### Parameters

x
Type: System..::..Double
On entry: $\beta$, the deviate from the beta distribution, for which the probability $P\left(B\le \beta :a,b\text{;}\lambda \right)$ is to be found.
Constraint: $0.0\le {\mathbf{x}}\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}$.
rlamda
Type: System..::..Double
On entry: $\lambda$, the noncentrality parameter of the required beta distribution.
Constraint: $0.0\le {\mathbf{rlamda}}\le -2.0\mathrm{log}\left(U\right)$, where $U$ is the safe range parameter as defined by x02am.
tol
Type: System..::..Double
On entry: the relative accuracy required by you in the results. If g01ge is entered with tol greater than or equal to $1.0$ or less than  (see x02aj), then the value of  is used instead.
See [Accuracy] for the relationship between tol and maxit.
maxit
Type: System..::..Int32
On entry: the maximum number of iterations that the algorithm should use.
See [Accuracy] for suggestions as to suitable values for maxit for different values of the parameters.
Suggested value: $500$.
Constraint: ${\mathbf{maxit}}\ge 1$.
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

g01ge returns the probability associated with the lower tail of the noncentral beta distribution.

# Description

The lower tail probability for the noncentral beta distribution with parameters $a$ and $b$ and noncentrality parameter $\lambda$, $P\left(B\le \beta :a,b\text{;}\lambda \right)$, is defined by
 $PB≤β:a,b;λ=∑j=0∞e-λ/2λ/2j!PB≤β:a,b;0,$ (1)
where
 $PB≤β:a,b;0=Γa+bΓaΓb∫0βBa-11-Bb-1dB,$
which is the central beta probability function or incomplete beta function.
Recurrence relationships given in Abramowitz and Stegun (1972) are used to compute the values of $P\left(B\le \beta :a,b\text{;}0\right)$ for each step of the summation (1).
The algorithm is discussed in Lenth (1987).

# References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Lenth R V (1987) Algorithm AS 226: Computing noncentral beta probabilities Appl. Statist. 36 241–244

# Error Indicators and Warnings

Note: g01ge 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{a}}\le 0.0$, or ${\mathbf{a}}>{10}^{6}$, or ${\mathbf{b}}\le 0.0$, or ${\mathbf{b}}>{10}^{6}$, or ${\mathbf{rlamda}}<0.0$, or ${\mathbf{rlamda}}>-2.0\mathrm{log}\left(U\right)$, where $U=\text{}$ safe range parameter as defined by x02am, or ${\mathbf{x}}<0.0$, or ${\mathbf{x}}>1.0$, or ${\mathbf{maxit}}<1$.
If on exit ${\mathbf{ifail}}={1}$ then g01ge returns zero.
${\mathbf{ifail}}=2$
The solution has failed to converge in maxit iterations. You should try a larger value of maxit or tol. The returned value will be an approximation to the correct value.
${\mathbf{ifail}}=3$
The probability is too close to $0.0$ or $1.0$ for the algorithm to be able to calculate the required probability. g01ge will return $0.0$ or $1.0$ as appropriate, this should be a reasonable approximation.
${\mathbf{ifail}}=4$
The required accuracy was not achieved when calculating the initial value of $P\left(B\le \beta :a,b\text{;}\lambda \right)$. You should try a larger value of tol. The returned value will be an approximation to the correct value.
${\mathbf{ifail}}=-9000$
An error occured, see message report.

# Accuracy

Convergence is theoretically guaranteed whenever $P\left(Y>{\mathbf{maxit}}\right)\le {\mathbf{tol}}$ where $Y$ has a Poisson distribution with mean $\lambda /2$. Excessive round-off errors are possible when the number of iterations used is high and tol is close to machine precision. See Lenth (1987) for further comments on the error bound.

# Parallelism and Performance

None.

The central beta probabilities can be obtained by setting ${\mathbf{rlamda}}=0.0$.

# Example

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

Example program (C#): g01gee.cs

Example program data: g01gee.d

Example program results: g01gee.r