﻿ g01ef Method
g01ef returns the lower or upper tail probability of the gamma distribution, with parameters $\alpha$ and $\beta$.

# Syntax

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

#### Parameters

tail
Type: System..::..String
On entry: indicates whether an upper or lower tail probability is required.
${\mathbf{tail}}=\text{"L"}$
The lower tail probability is returned, that is $P\left(G\le g:\alpha ,\beta \right)$.
${\mathbf{tail}}=\text{"U"}$
The upper tail probability is returned, that is $P\left(G\ge g:\alpha ,\beta \right)$.
Constraint: ${\mathbf{tail}}=\text{"L"}$ or $\text{"U"}$.
g
Type: System..::..Double
On entry: $g$, the value of the gamma variate.
Constraint: ${\mathbf{g}}\ge 0.0$.
a
Type: System..::..Double
On entry: the parameter $\alpha$ of the gamma distribution.
Constraint: ${\mathbf{a}}>0.0$.
b
Type: System..::..Double
On entry: the parameter $\beta$ of the gamma distribution.
Constraint: ${\mathbf{b}}>0.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

g01ef returns the lower or upper tail probability of the gamma distribution, with parameters $\alpha$ and $\beta$.

# Description

The lower tail probability for the gamma distribution with parameters $\alpha$ and $\beta$, $P\left(G\le g\right)$, is defined by:
 $PG≤g;α,β=1βαΓα∫0gGα-1e-G/βdG, α>0.0, ​β>0.0.$
The mean of the distribution is $\alpha \beta$ and its variance is $\alpha {\beta }^{2}$. The transformation $Z=\frac{G}{\beta }$ is applied to yield the following incomplete gamma function in normalized form,
 $PG≤g;α,β=PZ≤g/β:α,1.0=1Γα∫0g/βZα-1e-ZdZ.$
This is then evaluated using s14ba.

# References

Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth

# Error Indicators and Warnings

Errors or warnings detected by the method:
If ${\mathbf{ifail}}={1}$${2}$${3}$ or ${4}$ on exit, then g01ef returns $0.0$.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{tail}}\ne \text{"L"}$ or $\text{"U"}$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{g}}<0.0$.
${\mathbf{ifail}}=3$
 On entry, ${\mathbf{a}}\le 0.0$, or ${\mathbf{b}}\le 0.0$.
${\mathbf{ifail}}=4$
The solution did not converge in $600$ iterations. See s14ba. The probability returned should be a reasonable approximation to the solution.
${\mathbf{ifail}}=-9000$
An error occured, see message report.

# Accuracy

The result should have a relative accuracy of machine precision. There are rare occasions when the relative accuracy attained is somewhat less than machine precision but the error should not exceed more than $1$ or $2$ decimal places. Note also that there is a limit of $18$ decimal places on the achievable accuracy, because constants in s14ba are given to this precision.

# Parallelism and Performance

None.

The time taken by g01ef varies slightly with the input parameters g, a and b.

# Example

This example reads in values from a number of gamma distributions and computes the associated lower tail probabilities.

Example program (C#): g01efe.cs

Example program data: g01efe.d

Example program results: g01efe.r