# Chi2Cdf

Chi-square Distribution function: returns the cumulative probability density function for the χ2 probability density function.

## Contents

### Syntax

return = Chi2Cdf( X2 ;DegreesOfFreedom; PivotDim1 = -1; PivotDim2 = -1);

### Return Value

If X2 = 0 and DegreesOfFreedom >0 then the return value is the area under the χ2 probability function (see Chi2Pdf()), else the return value is 0.

### Parameters

 X2 Structure or matrix with numerical values. X2 = 0 DegreesOfFreedom Structure of matrix with the degrees of freedom, number values. DegreesOfFreedom > 0 PivotDim1 one single integer value assigning the pivotal dimension of X2. If not specified, the last dimension is the pivotal dimension. PivotDim1 <> 0 PivotDim2 one single integer value assigning the pivotal dimension of DegreesOfFreedom. If not specified, the last dimension is the pivotal dimension. PivotDim2 <> 0

### Explanation

In the figure, the pdf and cdf for the χ2-distribution with 4 degrees of freedom are shown. The area under the pdf is 0.95 which is the same value for the CDF for X2 equal to 9.487750. The formula for the PDF function is

${\displaystyle F(\chi ^{2})=\int \limits _{0}^{\chi ^{2}}{\frac {e^{-{\frac {1}{2}}}y^{{\frac {1}{2}}df-1}}{2^{{\frac {1}{2}}df}\Gamma ({\frac {1}{2}}df)}}dy}$

The formula is approximated by the formula on page 946 of

Abramowitz, M. and Stegun, I. A., 1972. Handbook of mathematical functions. Dover Publications inc., New York..

### Example

        x2 = (0#0.5#10)';
df = 2#4;
Write("x2", ("Df="+df));
Write(x2, Chi2Cdf(x2; df));

which has the following output

x2          Df=2            Df=3            Df=4
0.000000	0.000000	0.000000	0.000000
0.500000	0.221199	0.081109	0.026499
1.000000	0.393469	0.198748	0.090204
1.500000	0.527633	0.317730	0.173359
2.000000	0.632121	0.427593	0.264241
2.500000	0.713495	0.524709	0.355364
3.000000	0.776870	0.608375	0.442175
3.500000	0.826226	0.679238	0.522122
4.000000	0.864665	0.738536	0.593994
4.500000	0.894601	0.787710	0.657453
5.000000	0.917915	0.828203	0.712703
5.500000	0.936072	0.861361	0.760271
6.000000	0.950213	0.888390	0.800852
6.500000	0.961226	0.910337	0.835210
7.000000	0.969803	0.928102	0.864112
7.500000	0.976482	0.942441	0.888291
8.000000	0.981684	0.953988	0.908422
8.500000	0.985736	0.963267	0.925113
9.000000	0.988891	0.970709	0.938901
9.500000	0.991348	0.976669	0.950253
10.000000	0.993262	0.981434	0.959572