Next: Noncentral Chi-squared Random Variable, Previous: Noncentral Student’s t Random Variable, Up: Functions and Variables for continuous distributions [Contents][Index]

#### 52.2.4 Chi-squared Random Variable

Let \(X_1, X_2, \ldots, X_n\) be independent and identically distributed \({\it Normal}(0, 1)\) variables. Then $$ X^2 = \sum_{i=1}^n X_i^2 $$

is said to follow a chi-square distribution with \(n\) degrees of freedom.

Function: pdf_chi2 (x,n) ¶

  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

  $$ f(x; n) = \cases{ \displaystyle{x^{n/2-1} e^{-x/2} \over 2^{n/2} \Gamma\left(\displaystyle{n\over 2}\right)} & for $x > 0$ \cr \cr 0 & otherwise } $$

      (%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

  Categories: Package distrib ·

Function: cdf_chi2 (x,n) ¶

  Returns the value at \(x\) of the distribution function of a Chi-square random variable \(\chi^2(n)\) , with \(n>0\).

  The cdf is $$ F(x; n) = \cases{ 1 - Q\left(\displaystyle{n\over 2}, {x\over 2}\right) & $x > 0$ \cr 0 & otherwise } $$

  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

  Categories: Package distrib ·

Function: quantile_chi2 (q,n) ¶

  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

  Categories: Package distrib ·

Function: mean_chi2 (n) ¶

  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 $$ E[X] = n $$

      (%i1) load ("distrib")$

      (%i2) mean_chi2(n);
      (%o2)                           n

  Categories: Package distrib ·

Function: var_chi2 (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 $$ V[X] = 2n $$

      (%i1) load ("distrib")$

      (%i2) var_chi2(n);
      (%o2)                          2 n

  Categories: Package distrib ·

Function: std_chi2 (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 $$ D[X] = \sqrt{2n} $$

      (%i1) load ("distrib")$

      (%i2) std_chi2(n);
      (%o2)                    sqrt(2) sqrt(n)

  Categories: Package distrib ·

Function: skewness_chi2 (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 $$ SK[X] = \sqrt{8\over n} $$

      (%i1) load ("distrib")$

      (%i2) skewness_chi2(n);
                                     3/2
                                    2
      (%o2)                        -------
                                   sqrt(n)

  Categories: Package distrib ·

Function: kurtosis_chi2 (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 $$ KU[X] = {12\over n} $$

      (%i1) load ("distrib")$

      (%i2) kurtosis_chi2(n);
                                     12
      (%o2)                          --
                                     n

  Categories: Package distrib ·

Function: random_chi2 (n)
`random_chi2` (n,m) ¶

  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")`.

  Categories: Package distrib · Random numbers ·

Next: Noncentral Chi-squared Random Variable, Previous: Noncentral Student’s t Random Variable, Up: Functions and Variables for continuous distributions [Contents][Index]

JavaScript license information