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
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
which can be numerically approximated by:
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
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
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