Next: Noncentral Chi-squared Random Variable, Previous: Noncentral Student’s t Random Variable, Up: Functions and Variables for continuous distributions [Contents][Index]
Let \(X_1, X_2, \ldots, X_n\) be independent and identically distributed \({\it Normal}(0, 1)\) variables. Then
is said to follow a chi-square distribution with \(n\) degrees of freedom.
Returns the value at x of the density function of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\). The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .
The pdf is
(%i1) load ("distrib")$
(%i2) pdf_chi2(x,n); n/2 - 1 - x/2 x %e unit_step(x) (%o2) ----------------------------- n n/2 gamma(-) 2 2
Returns the value at \(x\) of the distribution function of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).
The cdf is
where \(Q(a,z)\) is the gamma_incomplete_regularized function.
(%i1) load ("distrib")$
(%i2) cdf_chi2(3,4); 3 (%o2) 1 - gamma_incomplete_regularized(2, -) 2
(%i3) float(%); (%o3) 0.4421745996289252
Returns the q-quantile of a Chi-square random variable
\(\chi^2(n)\)
, with \(n>0\); in other words, this is the inverse of cdf_chi2
. Argument q must be an element of \([0,1]\).
This function has no closed form and it is numerically computed.
(%i1) load ("distrib")$
(%i2) quantile_chi2(0.99,9); (%o2) 21.66599433346194
Returns the mean of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).
The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .
The mean is
(%i1) load ("distrib")$
(%i2) mean_chi2(n); (%o2) n
Returns the variance of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).
The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .
The variance is
(%i1) load ("distrib")$
(%i2) var_chi2(n); (%o2) 2 n
Returns the standard deviation of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).
The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .
The standard deviation is
(%i1) load ("distrib")$
(%i2) std_chi2(n); (%o2) sqrt(2) sqrt(n)
Returns the skewness coefficient of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).
The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .
The skewness coefficient is
(%i1) load ("distrib")$
(%i2) skewness_chi2(n); 3/2 2 (%o2) ------- sqrt(n)
Returns the kurtosis coefficient of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).
The \(\chi^2(n)\) random variable is equivalent to the \(\Gamma\left(n/2,2\right)\) .
The kurtosis coefficient is
(%i1) load ("distrib")$
(%i2) kurtosis_chi2(n); 12 (%o2) -- n
Returns a Chi-square random variate
\(\chi^2(n)\)
, with \(n>0\). Calling random_chi2
with a second argument m, a random sample of size m will be simulated.
The simulation is based on the Ahrens-Cheng algorithm. See random_gamma
for details.
To make use of this function, write first load("distrib")
.