g01ec returns the lower or upper tail probability for the ${\chi }^{2}$-distribution with real degrees of freedom.

Syntax

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

Parameters

tail
Type: System..::..String
On entry: indicates whether the upper or lower tail probability is required.
${\mathbf{tail}}=\text{"L"}$
The lower tail probability is returned, i.e., $P\left(X\le x:\nu \right)$.
${\mathbf{tail}}=\text{"U"}$
The upper tail probability is returned, i.e., $P\left(X\ge x:\nu \right)$.
Constraint: ${\mathbf{tail}}=\text{"L"}$ or $\text{"U"}$.
x
Type: System..::..Double
On entry: $x$, the value of the ${\chi }^{2}$ variate with $\nu$ degrees of freedom.
Constraint: ${\mathbf{x}}\ge 0.0$.
df
Type: System..::..Double
On entry: $\nu$, the degrees of freedom of the ${\chi }^{2}$-distribution.
Constraint: ${\mathbf{df}}>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

g01ec returns the lower or upper tail probability for the ${\chi }^{2}$-distribution with real degrees of freedom.

Description

The lower tail probability for the ${\chi }^{2}$-distribution with $\nu$ degrees of freedom, $P\left(X\le x:\nu \right)$ is defined by:
 $PX≤x:ν=12ν/2Γν/2∫0.0xXν/2-1e-X/2dX, x≥0,ν>0.$
To calculate $P\left(X\le x:\nu \right)$ a transformation of a gamma distribution is employed, i.e., a ${\chi }^{2}$-distribution with $\nu$ degrees of freedom is equal to a gamma distribution with scale parameter $2$ and shape parameter $\nu /2$.

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

Error Indicators and Warnings

Note: g01ec may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
If ${\mathbf{ifail}}={1}$${2}$ or ${3}$ on exit, then g01ec returns $0.0$.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{tail}}\ne \text{"L"}$ or $\text{"U"}$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{x}}<0.0$.
${\mathbf{ifail}}=3$
 On entry, ${\mathbf{df}}\le 0.0$.
${\mathbf{ifail}}=4$
The solution has failed to converge while calculating the gamma variate. The result returned should represent an approximation to the solution.
${\mathbf{ifail}}=-9000$
An error occured, see message report.

Accuracy

A relative accuracy of five significant figures is obtained in most cases.

Parallelism and Performance

None.

For higher accuracy the transformation described in [Description] may be used with a direct call to s14ba.

Example

Values from various ${\chi }^{2}$-distributions are read, the lower tail probabilities calculated, and all these values printed out, until the end of data is reached.

Example program (C#): g01ece.cs

Example program data: g01ece.d

Example program results: g01ece.r