g01ec returns the lower or upper tail probability for the χ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.
tail="L"
The lower tail probability is returned, i.e., PXx:ν.
tail="U"
The upper tail probability is returned, i.e., PXx:ν.
Constraint: tail="L" or "U".
x
Type: System..::..Double
On entry: x, the value of the χ2 variate with ν degrees of freedom.
Constraint: x0.0.
df
Type: System..::..Double
On entry: ν, the degrees of freedom of the χ2-distribution.
Constraint: df>0.0.
ifail
Type: System..::..Int32%
On exit: 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 χ2-distribution with real degrees of freedom.

Description

The lower tail probability for the χ2-distribution with ν degrees of freedom, PXx:ν is defined by:
PXx:ν=12ν/2Γν/20.0xXν/2-1e-X/2dX,  x0,ν>0.
To calculate PXx:ν a transformation of a gamma distribution is employed, i.e., a χ2-distribution with ν degrees of freedom is equal to a gamma distribution with scale parameter 2 and shape parameter ν/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 ifail=12 or 3 on exit, then g01ec returns 0.0.
ifail=1
On entry,tail"L" or "U".
ifail=2
On entry,x<0.0.
ifail=3
On entry,df0.0.
ifail=4
The solution has failed to converge while calculating the gamma variate. The result returned should represent an approximation to the solution.
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.

Further Comments

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

Example

Values from various χ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

See Also