χ2 distribution

### 20.4.9 χ2 distribution

##### The probability density function for the χ2 distribution.

The χ2 distribution with n degrees of freedom has density function given by

χ2(n,x)= |
xn/2−1e−x/2
2n/2Γ(n/2)
| . (6)

The chisquare command computes this density function.

- chisquare takes two arguments:
  - n, an integer (the degrees of freedom).
  - x, a real number.
- chisquare(n,x) returns the value of the χ2 density function with n degrees of freedom, given in (6).

#### Example

chisquare(5,2)

2 | √ |
2
e | ⎛ ⎜ ⎜ ⎝ |
3
4
|  | √ |
π
|  | √ |
2
| · 22 | ⎞ ⎟ ⎟ ⎠

which can be numerically approximated by:

evalf(chisquare(5,2))

0.138369165807 |  |  |  |  |  |  |  |  |  |

##### The cumulative distribution function for the χ2 distribution.

The chisquare_cdf command computes the cumulative distribution function for the χ2 distribution.

- chisquare_cdf takes two mandatory arguments and one optional argument:
  - n, an integer (the degrees of freedom).
  - x, a real number.
  - Optionally, y, a real number.
- chisquare_cdf(n,x) returns Prob(X ≤ x) for the χ2 distribution with n degrees of freedom.
- chisquare_cdf(n,x,y) returns Prob(x ≤ X < y).

#### Examples

chisquare_cdf(5,11)

0.948620016517 |  |  |  |  |  |  |  |  |  |

chisquare_cdf(3,1,2)

0.22884525243 |  |  |  |  |  |  |  |  |  |

##### The inverse distribution function for the χ2 distribution.

The chisquare_icdf command computes the inverse distribution for the χ2 distribution.

- chisquare_icdf takes two arguments:
  - n, an integer (the degrees of freedom).
  - h, a real number between 0 and 1.
- chisquare_icdf(n, h) returns the inverse distribution for the χ2 distribution with n degrees of freedom; namely, the value of x for which Prob(X ≤ x)=h.

#### Example

chisquare_icdf(5,0.95)

11.0704976935 |  |  |  |  |  |  |  |  |  |

##### The upper tail cumulative function for the χ2 distribution.

The UTPC (the Upper Tail Probability-Chi-square distribution) computes Prob(X > x) for the χ2 distribution.

- UTPC takes two arguments:
  - n, an integer (the degrees of freedom).
  - x, a real number.
- UTPC(n,x) returns Prob(X > x) for the χ2 distribution with n degrees of freedom.

#### Example

UTPC(5,11)

0.0513799834831 |  |  |  |  |  |  |  |  |  |