Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

The chi-square distribution is commonly used in hypothesis testing, particularly the chi-squared test for goodness of fit.

The chi-square distribution uses the following parameter.

Parameter | Description | Support |
---|---|---|

ν | Degrees of freedom | ν is a positive value |

The probability density function (pdf) is

$$y=f\left(x|\nu \right)=\frac{{x}^{\left(\nu -2\right)/2}{e}^{-x/2}}{{2}^{\frac{\nu}{2}}\Gamma \left(\nu /2\right)}$$

where Γ( · ) is the Gamma function, ν is the
degrees of freedom, and *x* ≥ `0`

.

The cumulative distribution function (cdf) is

$$p=F(x|\nu )={\displaystyle {\int}_{0}^{x}\frac{{t}^{(\nu -2)/2}{e}^{-t/2}}{{2}^{\nu /2}\Gamma (\nu /2)}dt}$$

where Γ( · ) is the Gamma
function, ν is the degrees of freedom, and *x* ≥ `0`

.

The mean is ν.

The variance is `2`

ν.

The *χ*^{2} distribution
is a special case of the gamma distribution where *b* =
2 in the equation for gamma distribution below.

$$y=f\left(x|a,b\right)=\frac{1}{{b}^{a}\Gamma \left(a\right)}{x}^{a-1}{e}^{\frac{x}{b}}$$

The *χ*^{2} distribution gets special attention
because of its importance in normal sampling theory. If a set of
*n* observations is normally distributed with variance
*σ*^{2}, and
*s*^{2} is the sample variance,
then

$$\frac{\left(n-1\right){s}^{2}}{{\sigma}^{2}}\sim {\chi}^{2}\left(n-1\right)$$

This relationship is used to calculate confidence intervals for the estimate of the normal
parameter *σ*^{2 } in the function
`normfit`

.

Compute the pdf of a chi-square distribution with 4 degrees of freedom.

x = 0:0.2:15; y = chi2pdf(x,4);

Plot the pdf.

figure; plot(x,y)

The chi-square distribution is skewed to the right, especially for few degrees of freedom.

`chi2cdf`

| `chi2gof`

| `chi2inv`

| `chi2pdf`

| `chi2rnd`

| `chi2stat`

| `random`