g01gc returns the probability associated with the lower tail of the noncentral ${\chi }^{2}$-distribution .

# Syntax

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

#### Parameters

x
Type: System..::..Double
On entry: the deviate from the noncentral ${\chi }^{2}$-distribution with $\nu$ degrees of freedom and noncentrality parameter $\lambda$.
Constraint: ${\mathbf{x}}\ge 0.0$.
df
Type: System..::..Double
On entry: $\nu$, the degrees of freedom of the noncentral ${\chi }^{2}$-distribution.
Constraint: ${\mathbf{df}}\ge 0.0$.
rlamda
Type: System..::..Double
On entry: $\lambda$, the noncentrality parameter of the noncentral ${\chi }^{2}$-distribution.
Constraint: ${\mathbf{rlamda}}\ge 0.0$ if ${\mathbf{df}}>0.0$ or ${\mathbf{rlamda}}>0.0$ if ${\mathbf{df}}=0.0$.
tol
Type: System..::..Double
On entry: the required accuracy of the solution. If g01gc is entered with tol greater than or equal to $1.0$ or less than  (see x02aj), then the value of  is used instead.
maxit
Type: System..::..Int32
On entry: the maximum number of iterations to be performed.
Suggested value: $100$. See [Further Comments] for further discussion.
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

g01gc returns the probability associated with the lower tail of the noncentral ${\chi }^{2}$-distribution .

# Description

The lower tail probability of the noncentral ${\chi }^{2}$-distribution with $\nu$ degrees of freedom and noncentrality parameter $\lambda$, $P\left(X\le x:\nu \text{;}\lambda \right)$, is defined by
 $PX≤x:ν;λ=∑j=0∞e-λ/2λ/2jj!PX≤x:ν+2j;0,$ (1)
where $P\left(X\le x:\nu +2j\text{;}0\right)$ is a central ${\chi }^{2}$-distribution with $\nu +2j$ degrees of freedom.
The value of $j$ at which the Poisson weight, ${e}^{-\lambda /2}\frac{{\left(\lambda /2\right)}^{j}}{j!}$, is greatest is determined and the summation (1) is made forward and backward from that value of $j$.
The recursive relationship:
 $PX≤x:a+2;0=PX≤x:a;0-xa/2e-x/2Γa+1$ (2)
is used during the summation in (1).

# References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

# Error Indicators and Warnings

Note: g01gc may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
If on exit ${\mathbf{ifail}}={1}$${2}$${4}$ or ${5}$, then g01gc returns $0.0$.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{df}}<0.0$, or ${\mathbf{rlamda}}<0.0$, or ${\mathbf{df}}=0.0$ and ${\mathbf{rlamda}}=0.0$, or ${\mathbf{x}}<0.0$, or ${\mathbf{maxit}}<1$.
${\mathbf{ifail}}=2$
The initial value of the Poisson weight used in the summation (1) was too small to be calculated. The value of $P\left({\mathbf{x}}\le x:\nu \text{;}\lambda \right)$ is likely to be zero.
${\mathbf{ifail}}=3$
The solution has failed to converge in maxit iterations.
${\mathbf{ifail}}=4$
The value of a term required in (2) is too large to be evaluated accurately. The most likely cause of this error is both x and rlamda being very large.
${\mathbf{ifail}}=5$
The calculations for the central ${\chi }^{2}$ probability has failed to converge. This is an unlikely error exit. A larger value of tol should be used.
${\mathbf{ifail}}=-9000$
An error occured, see message report.

# Accuracy

The summations described in [Description] are made until an upper bound on the truncation error relative to the current summation value is less than tol.

# Parallelism and Performance

None.

The number of terms in (1) required for a given accuracy will depend on the following factors:
 (i) The rate at which the Poisson weights tend to zero. This will be slower for larger values of $\lambda$. (ii) The rate at which the central ${\chi }^{2}$ probabilities tend to zero. This will be slower for larger values of $\nu$ and $x$.

# Example

This example reads values from various noncentral ${\chi }^{2}$-distributions, calculates the lower tail probabilities and prints all these values until the end of data is reached.

Example program (C#): g01gce.cs

Example program data: g01gce.d

Example program results: g01gce.r