Chi-squared distribution

From Infogalactic: the planetary knowledge core
(Redirected from Chi-square distribution)
Jump to: navigation, search

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

chi-squared
Probability density function
Chi-square pdf.svg
Cumulative distribution function
Chi-square cdf.svg
Notation \chi^2(k)\! or \chi^2_k\!
Parameters k \in \mathbb{N}_{>0}~~ (known as "degrees of freedom")
Support x ∈ [0, +∞)
PDF \frac{1}{2^{\frac{k}{2}}\Gamma\left(\frac{k}{2}\right)}\; x^{\frac{k}{2}-1} e^{-\frac{x}{2}}\,
CDF \frac{1}{\Gamma\left(\frac{k}{2}\right)}\;\gamma\left(\frac{k}{2},\,\frac{x}{2}\right)
Mean k
Median \approx k\bigg(1-\frac{2}{9k}\bigg)^3
Mode max{ k − 2, 0 }
Variance 2k
Skewness \scriptstyle\sqrt{8/k}\,
Ex. kurtosis 12 / k
Entropy \begin{align}\frac{k}{2}&+\ln(2\Gamma(k/2)) \\ &\!+(1-k/2)\psi(k/2)\end{align}
MGF (1 − 2 t)k/2   for  t  < ½
CF (1 − 2 it)k/2      [1]

In probability theory and statistics, the chi-squared distribution (also chi-square or χ²-distribution) with k degrees of freedom is the distribution of a sum of the squares of k independent standard normal random variables. It is a special case of the gamma distribution and is one of the most widely used probability distributions in inferential statistics, e.g., in hypothesis testing or in construction of confidence intervals.[2][3][4][5] When it is being distinguished from the more general noncentral chi-squared distribution, this distribution is sometimes called the central chi-squared distribution.

The chi-squared distribution is used in the common chi-squared tests for goodness of fit of an observed distribution to a theoretical one, the independence of two criteria of classification of qualitative data, and in confidence interval estimation for a population standard deviation of a normal distribution from a sample standard deviation. Many other statistical tests also use this distribution, like Friedman's analysis of variance by ranks.

Definition

If Z1, ..., Zk are independent, standard normal random variables, then the sum of their squares,


    Q\ = \sum_{i=1}^k Z_i^2 ,

is distributed according to the chi-squared distribution with k degrees of freedom. This is usually denoted as


    Q\ \sim\ \chi^2(k)\ \ \text{or}\ \ Q\ \sim\ \chi^2_k .

The chi-squared distribution has one parameter: k — a positive integer that specifies the number of degrees of freedom (i.e. the number of Zi’s)

Introduction to the chi-squared distribution

The chi-squared distribution is used primarily in hypothesis testing. Unlike more widely-known distributions such as the normal distribution and the exponential distribution, the chi-squared distribution is rarely used to model natural phenomena. It arises in the following hypothesis tests, among others.

It is also a component of the definition of the t-distribution and the F-distribution used in t-tests, analysis of variance, and regression analysis.

The primary reason that the chi-squared distribution is used extensively in hypothesis testing is its relationship to the normal distribution. Many hypothesis tests use a test statistic, such as the t statistic in a t-test. For these hypothesis tests, as the sample size, n, increases, the sampling distribution of the test statistic approaches the normal distribution (Central Limit Theorem). Because the test statistic (such as t) is asymptotically normally distributed, provided the sample size is sufficiently large, the distribution used for hypothesis testing may be approximated by a normal distribution. Testing hypotheses using a normal distribution is well understood and relatively easy. The simplest chi-squared distribution is the square of a standard normal distribution. So wherever a normal distribution could be used for a hypothesis test, a chi-squared distribution could be used.

Specifically, suppose that Z is a standard normal random variable, with mean = 0 and variance = 1. Z ~ N(0,1). A sample drawn at random from Z is a sample from the distribution shown in the graph of the standard normal distribution. Define a new random variable Q. To generate a random sample from Q, take a sample from Z and square the value. The distribution of the squared values is given by the random variable Q = Z2. The distribution of the random variable Q is an example of a chi-squared distribution: 
     \ Q\ \sim\ \chi^2_1 .
  The subscript 1 indicates that this particular chi-squared distribution is constructed from only 1 standard normal distribution. A chi-squared distribution constructed by squaring a single standard normal distribution is said to have 1 degree of freedom. Thus, as the sample size for a hypothesis test increases, the distribution of the test statistic approaches a normal distribution. and the distribution of the square of the test statistic approaches a chi-squared distribution. Just as extreme values of the normal distribution have low probability (and give small p-values), extreme values of the chi-squared distribution have low probability.

An additional reason that the chi-squared distribution is widely used is that it is a member of the class of likelihood ratio tests (LRT).[6] LRT's have several desirable properties; in particular, LRT's commonly provide the highest power to reject the null hypothesis (Neyman–Pearson lemma). However, the normal and chi-squared approximations are only valid asymptotically. For this reason, it is preferable to use the t distribution rather than the normal approximation or the chi-squared approximation for small sample size. Similarly, in analyses of contingency tables, the chi-squared approximation will be poor for small sample size, and it is preferable to use the Fisher Exact test. Ramsey and Ramsey show that the exact binomial test is always more powerful than the normal approximation.[7]

Where are the squared normal distributions?

If the chi-squared distribution is used because it is the sum of squared normal distributions, why are the squared normal distributions in contingency tables analyzed with a chi-squared test? The answer can be traced back to the normal approximation to the binomial distribution. Consider an experiment in which 10 fair coins are tossed, and the number of heads is observed. This experiment can be modeled with a binomial distribution, with n=10 trials and p = 0.5 probability of heads on each trial. Suppose that heads is observed 1 times in 10 trials. What is the probability of a result as extreme as 1 heads in 10 trials, if the probability of heads is p=0.5?

Three methods to determine the probability are:

  • Calculate the probability exactly using the binomial distribution.
  • Estimate the probability using normal approximation to the binomial distribution.
  • Estimate the probability using a chi-squared test. This result will be the same as the result for the normal approximation.

Calculation using the exact binomial and the normal approximation may be performed using http://vassarstats.net/binomialX.html. Calculation of the chi-square probability may be performed using http://vassarstats.net/csfit.html.

Using the binomial distribution, the probability of a result as extreme 1 heads in 10 trials is the sum of the probabilities of 0 heads, 1 head, 9 heads, or 10 heads. Notice that this is a two-tailed or two-sided test. This test gives p=0.0215.

Using the normal approximation to the binomial distribution, the (two-sided) probability of a result as extreme 1 heads in 10 trials is p=0.0271.

The chi-squared test is performed as follows. The observed number of heads is 1, and the observed number of tails is 9. The expected number of heads = expected number of tails = 10*0.5 = 5. The difference between the observed and expected is 1-5=-4 for heads, and 9-5=4 for tails. The chi-squared statistic (with Yates's correction for continuity) is

 \chi^2 = {(|1 - 5|-0.5)^2 \over 5} + {(|9 - 5|-0.5)^2 \over 5} = 4.9.

For the chi-squared test, the (two-sided) probability of a result as extreme as 1 heads in 10 trials is p=0.027, the same as the result using the normal approximation. That is, the probability that the chi-squared statistic with one degree of freedom is greater than 4.9 is p=0.027.

Lancaster [8] shows the connections among the binomial, normal, and chi-squared distributions, as follows. De Moivre and Laplace established that a binomial distribution could be approximated by a normal distribution. Specifically they showed the asymptotic normality of the random variable

 \chi = {(m - Np)\over \sqrt{(Npq)}}

where m is the observed number of successes in N trials, where the probability of success is p, and q = 1 − p.

Squaring both sides of the equation gives

 \chi^2 = {(m - Np)^2\over (Npq)}

Using N = Np + N(1 − p), N = m + (Nm), and q = 1 − p, this equation simplifies to

 \chi^2 = {(m - Np)^2\over (Np)} + {(N - m - Nq)^2\over (Nq)}

The expression on the right is of the form that Pearson would generalize to the form:

 \chi^2 = \sum_{i=1}^{n} \frac{(O_i - E_i)^2}{E_i}

where

 \chi^2 = Pearson's cumulative test statistic, which asymptotically approaches a \chi^2 distribution.
O_i = the number of observations of type i.
E_i = N p_i = the expected (theoretical) frequency of type i, asserted by the null hypothesis that the fraction of type i in the population is  p_i
n = the number of cells in the table.

In the case of a binomial outcome (flipping a coin), the binomial distribution may be approximated by a normal distribution (for sufficiently large n). Because the square of a standard normal distribution is the chi-squared distribution with one degree of freedom, the probability of a result such as 1 heads in 10 trials can be approximated either by the normal or the chi-squared distribution. However, many problems involve more than the two possible outcomes of a binomial, and instead require 3 or more categories, which leads to the multinomial distribution. Just as de Moivre and Laplace sought for and found the normal approximation to the binomial, Pearson sought for and found a multivariate normal approximation to the multinomial distribution. Pearson showed that the chi-squared distribution, the sum of multiple normal distributions, was such an approximation to the multinomial distribution [8]

Characteristics

Further properties of the chi-squared distribution can be found in the box at the upper right corner of this article.

Probability density function

The probability density function (pdf) of the chi-squared distribution is


f(x;\,k) =
\begin{cases}
  \frac{x^{(k/2-1)} e^{-x/2}}{2^{k/2} \Gamma\left(\frac{k}{2}\right)},  & x > 0; \\ 0, & \text{otherwise}.
\end{cases}

where Γ(k/2) denotes the Gamma function, which has closed-form values for integer k.

For derivations of the pdf in the cases of one, two and k degrees of freedom, see Proofs related to chi-squared distribution.

Differential equation

The pdf of the chi-squared distribution is a solution to the following differential equation:

\left\{\begin{array}{l}
2 x f'(x)+f(x) (-k+x+2)=0, \\
f(1)=\frac{2^{-k/2}}{\sqrt{e}
   \Gamma \left(\frac{k}{2}\right)}
\end{array}\right\}

Cumulative distribution function

Chernoff bound for the CDF and tail (1-CDF) of a chi-squared random variable with ten degrees of freedom (k = 10)

Its cumulative distribution function is:


    F(x;\,k) = \frac{\gamma(\frac{k}{2},\,\frac{x}{2})}{\Gamma(\frac{k}{2})} = P\left(\frac{k}{2},\,\frac{x}{2}\right),

where γ(s,t) is the lower incomplete Gamma function and P(s,t) is the regularized Gamma function.

In a special case of k = 2 this function has a simple form:


    F(x;\,2) = 1 - e^{-\frac{x}{2}}

and the form is not much more complicated for other small even k.

Tables of the chi-squared cumulative distribution function are widely available and the function is included in many spreadsheets and all statistical packages.

Letting z \equiv x/k, Chernoff bounds on the lower and upper tails of the CDF may be obtained.[9] For the cases when 0 < z < 1 (which include all of the cases when this CDF is less than half):


    F(z k;\,k) \leq (z e^{1-z})^{k/2}.

The tail bound for the cases when z > 1, similarly, is


    1-F(z k;\,k) \leq (z e^{1-z})^{k/2}.

For another approximation for the CDF modeled after the cube of a Gaussian, see under Noncentral chi-squared distribution.

Additivity

It follows from the definition of the chi-squared distribution that the sum of independent chi-squared variables is also chi-squared distributed. Specifically, if {Xi}i=1n are independent chi-squared variables with {ki}i=1n degrees of freedom, respectively, then Y = X1 + ⋯ + Xn is chi-squared distributed with k1 + ⋯ + kn degrees of freedom.

Sample mean

The sample mean of n i.i.d. chi-squared variables of degree k is distributed according to a gamma distribution with shape \alpha and scale \theta parameters:

 \bar X = \frac{1}{n} \sum_{i=1}^{n} X_i \sim \operatorname{Gamma}\left(\alpha=n\, k /2, \theta= 2/n \right)  \qquad \text{where} \quad X_i \sim \chi^2(k)

Asymptotically, given that for a scale parameter  \alpha going to infinity, a Gamma distribution converges towards a Normal distribution with expectation  \mu = \alpha\cdot \theta and variance  \sigma^2 = \alpha\, \theta^2 , the sample mean converges towards:

 \bar X  \xrightarrow{n \to \infty} N(\mu = k, \sigma^2 = 2\, k /n )

Note that we would have obtained the same result invoking instead the central limit theorem, noting that for each chi-squared variable of degree  k the expectation is  k , and its variance  2\,k (and hence the variance of the sample mean  \bar X being  \sigma^2 = 2\,k/n  ).

Entropy

The differential entropy is given by


    h = \int_{-\infty}^\infty f(x;\,k)\ln f(x;\,k) \, dx
      = \frac{k}{2} + \ln\!\left[2\,\Gamma\!\left(\frac{k}{2}\right)\right] + \left(1-\frac{k}{2}\right)\, \psi\!\left[\frac{k}{2}\right],

where ψ(x) is the Digamma function.

The chi-squared distribution is the maximum entropy probability distribution for a random variate X for which E(X)=k and E(\ln(X))=\psi\left(k/2\right)+log(2) are fixed. Since the chi-squared is in the family of gamma distributions, this can be derived by substituting appropriate values in the Expectation of the Log moment of Gamma. For derivation from more basic principles, see the derivation in moment generating function of the sufficient statistic.

Noncentral moments

The moments about zero of a chi-squared distribution with k degrees of freedom are given by[10][11]


    \operatorname{E}(X^m) = k (k+2) (k+4) \cdots (k+2m-2) = 2^m \frac{\Gamma(m+\frac{k}{2})}{\Gamma(\frac{k}{2})}.

Cumulants

The cumulants are readily obtained by a (formal) power series expansion of the logarithm of the characteristic function:


    \kappa_n = 2^{n-1}(n-1)!\,k

Asymptotic properties

By the central limit theorem, because the chi-squared distribution is the sum of k independent random variables with finite mean and variance, it converges to a normal distribution for large k. For many practical purposes, for k > 50 the distribution is sufficiently close to a normal distribution for the difference to be ignored.[12] Specifically, if X ~ χ²(k), then as k tends to infinity, the distribution of (X-k)/\sqrt{2k} tends to a standard normal distribution. However, convergence is slow as the skewness is \sqrt{8/k} and the excess kurtosis is 12/k.

  • The sampling distribution of ln(χ2) converges to normality much faster than the sampling distribution of χ2,[13] as the logarithm removes much of the asymmetry.[14] Other functions of the chi-squared distribution converge more rapidly to a normal distribution. Some examples are:
  • If X ~ χ²(k) then \scriptstyle\sqrt{2X} is approximately normally distributed with mean \scriptstyle\sqrt{2k-1} and unit variance (result credited to R. A. Fisher).
  • If X ~ χ²(k) then \scriptstyle\sqrt[3]{X/k} is approximately normally distributed with mean \scriptstyle 1-2/(9k) and variance \scriptstyle 2/(9k) .[15] This is known as the Wilson–Hilferty transformation.

Relation to other distributions

Approximate formula for median compared with numerical quantile (top). Difference between numerical quantile and approximate formula (bottom).

A chi-squared variable with k degrees of freedom is defined as the sum of the squares of k independent standard normal random variables.

If Y is a k-dimensional Gaussian random vector with mean vector μ and rank k covariance matrix C, then X = (Yμ)TC−1(Yμ) is chi-squared distributed with k degrees of freedom.

The sum of squares of statistically independent unit-variance Gaussian variables which do not have mean zero yields a generalization of the chi-squared distribution called the noncentral chi-squared distribution.

If Y is a vector of k i.i.d. standard normal random variables and A is a k×k symmetric, idempotent matrix with rank k−n then the quadratic form YTAY is chi-squared distributed with k−n degrees of freedom.

The chi-squared distribution is also naturally related to other distributions arising from the Gaussian. In particular,

  • Y is F-distributed, Y ~ F(k1,k2) if \scriptstyle Y = \frac{X_1 / k_1}{X_2 / k_2} where X1 ~ χ²(k1) and X2  ~ χ²(k2) are statistically independent.
  • If X is chi-squared distributed, then \scriptstyle\sqrt{X} is chi distributed.
  • If X1  ~  χ2k1 and X2  ~  χ2k2 are statistically independent, then X1 + X2  ~ χ2k1+k2. If X1 and X2 are not independent, then X1 + X2 is not chi-squared distributed.

Generalizations

The chi-squared distribution is obtained as the sum of the squares of k independent, zero-mean, unit-variance Gaussian random variables. Generalizations of this distribution can be obtained by summing the squares of other types of Gaussian random variables. Several such distributions are described below.

Linear combination

If X_1,...,X_n are chi square random variables and a_1,...,a_n\in\mathbb{R}_{>0}, then a closed expression for the distribution of X=\sum_{i=1}^n a_iX_i is not known. It may be, however, calculated using the property of characteristic functions of the chi-squared random variable.[16]

Chi-squared distributions

Noncentral chi-squared distribution

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

The noncentral chi-squared distribution is obtained from the sum of the squares of independent Gaussian random variables having unit variance and nonzero means.

Generalized chi-squared distribution

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

The generalized chi-squared distribution is obtained from the quadratic form z′Az where z is a zero-mean Gaussian vector having an arbitrary covariance matrix, and A is an arbitrary matrix.

Gamma, exponential, and related distributions

The chi-squared distribution X ~ χ²(k) is a special case of the gamma distribution, in that X ~ Γ(k/2, 1/2) using the rate parameterization of the gamma distribution (or X ~ Γ(k/2, 2) using the scale parameterization of the gamma distribution) where k is an integer.

Because the exponential distribution is also a special case of the Gamma distribution, we also have that if X ~ χ²(2), then X ~ Exp(1/2) is an exponential distribution.

The Erlang distribution is also a special case of the Gamma distribution and thus we also have that if X ~ χ²(k) with even k, then X is Erlang distributed with shape parameter k/2 and scale parameter 1/2.

Applications

The chi-squared distribution has numerous applications in inferential statistics, for instance in chi-squared tests and in estimating variances. It enters the problem of estimating the mean of a normally distributed population and the problem of estimating the slope of a regression line via its role in Student’s t-distribution. It enters all analysis of variance problems via its role in the F-distribution, which is the distribution of the ratio of two independent chi-squared random variables, each divided by their respective degrees of freedom.

Following are some of the most common situations in which the chi-squared distribution arises from a Gaussian-distributed sample.

  • if X1, ..., Xn are i.i.d. N(μ, σ2) random variables, then \sum_{i=1}^n(X_i - \bar X)^2 \sim \sigma^2 \chi^2_{n-1} where \bar X = \frac{1}{n} \sum_{i=1}^n X_i.
  • The box below shows some statistics based on Xi ∼ Normal(μi, σ2i), i = 1, ⋯, k, independent random variables that have probability distributions related to the chi-squared distribution:
Name Statistic
chi-squared distribution \sum_{i=1}^k \left(\frac{X_i-\mu_i}{\sigma_i}\right)^2
noncentral chi-squared distribution \sum_{i=1}^k \left(\frac{X_i}{\sigma_i}\right)^2
chi distribution \sqrt{\sum_{i=1}^k \left(\frac{X_i-\mu_i}{\sigma_i}\right)^2}
noncentral chi distribution \sqrt{\sum_{i=1}^k \left(\frac{X_i}{\sigma_i}\right)^2}

The chi-squared distribution is also often encountered in Magnetic Resonance Imaging .[17]

Table of χ2 value vs p-value

The p-value is the probability of observing a test statistic at least as extreme in a chi-squared distribution. Accordingly, since the cumulative distribution function (CDF) for the appropriate degrees of freedom (df) gives the probability of having obtained a value less extreme than this point, subtracting the CDF value from 1 gives the p-value. The table below gives a number of p-values matching to χ2 for the first 10 degrees of freedom.

A low p-value indicates greater statistical significance, i.e. greater confidence that the observed deviation from the null hypothesis is significant. A p-value of 0.05 is often used as a cutoff between significant and not-significant results.

Degrees of freedom (df) χ2 value[18]
1 0.004 0.02 0.06 0.15 0.46 1.07 1.64 2.71 3.84 6.64 10.83
2 0.10 0.21 0.45 0.71 1.39 2.41 3.22 4.60 5.99 9.21 13.82
3 0.35 0.58 1.01 1.42 2.37 3.66 4.64 6.25 7.82 11.34 16.27
4 0.71 1.06 1.65 2.20 3.36 4.88 5.99 7.78 9.49 13.28 18.47
5 1.14 1.61 2.34 3.00 4.35 6.06 7.29 9.24 11.07 15.09 20.52
6 1.63 2.20 3.07 3.83 5.35 7.23 8.56 10.64 12.59 16.81 22.46
7 2.17 2.83 3.82 4.67 6.35 8.38 9.80 12.02 14.07 18.48 24.32
8 2.73 3.49 4.59 5.53 7.34 9.52 11.03 13.36 15.51 20.09 26.12
9 3.32 4.17 5.38 6.39 8.34 10.66 12.24 14.68 16.92 21.67 27.88
10 3.94 4.87 6.18 7.27 9.34 11.78 13.44 15.99 18.31 23.21 29.59
P value (Probability) 0.95 0.90 0.80 0.70 0.50 0.30 0.20 0.10 0.05 0.01 0.001

History and name

This distribution was first described by the German statistician Friedrich Robert Helmert in papers of 1875-6,[19][20] where he computed the sampling distribution of the sample variance of a normal population. Thus in German this was traditionally known as the Helmert'sche ("Helmertian") or "Helmert distribution".

The distribution was independently rediscovered by the English mathematician Karl Pearson in the context of goodness of fit, for which he developed his Pearson's chi-squared test, published in 1900, with computed table of values published in (Elderton 1902), collected in (Pearson 1914, pp. xxxi–xxxiii, 26–28, Table XII). The name "chi-squared" ultimately derives from Pearson's shorthand for the exponent in a multivariate normal distribution with the Greek letter Chi, writing -½χ² for what would appear in modern notation as -½xTΣ−1x (Σ being the covariance matrix).[21] The idea of a family of "chi-squared distributions", however, is not due to Pearson but arose as a further development due to Fisher in the 1920s.[19]

See also

<templatestyles src="Div col/styles.css"/>

References

  1. Lua error in package.lua at line 80: module 'strict' not found.
  2. Lua error in package.lua at line 80: module 'strict' not found.
  3. NIST (2006). Engineering Statistics Handbook - Chi-Squared Distribution
  4. Lua error in package.lua at line 80: module 'strict' not found.
  5. Lua error in package.lua at line 80: module 'strict' not found.
  6. Lua error in package.lua at line 80: module 'strict' not found.
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. 8.0 8.1 Lua error in package.lua at line 80: module 'strict' not found.
  9. Lua error in package.lua at line 80: module 'strict' not found.
  10. Chi-squared distribution, from MathWorld, retrieved Feb. 11, 2009
  11. M. K. Simon, Probability Distributions Involving Gaussian Random Variables, New York: Springer, 2002, eq. (2.35), ISBN 978-0-387-34657-1
  12. Lua error in package.lua at line 80: module 'strict' not found.
  13. Lua error in package.lua at line 80: module 'strict' not found.
  14. Lua error in package.lua at line 80: module 'strict' not found.
  15. Lua error in package.lua at line 80: module 'strict' not found.
  16. Lua error in package.lua at line 80: module 'strict' not found.
  17. den Dekker A. J., Sijbers J., (2014) "Data distributions in magnetic resonance images: a review", Physica Medica, [1]
  18. Chi-Squared Test Table B.2. Dr. Jacqueline S. McLaughlin at The Pennsylvania State University. In turn citing: R.A. Fisher and F. Yates, Statistical Tables for Biological Agricultural and Medical Research, 6th ed., Table IV
  19. 19.0 19.1 Hald 1998, pp. 633–692, 27. Sampling Distributions under Normality.
  20. F. R. Helmert, "Ueber die Wahrscheinlichkeit der Potenzsummen der Beobachtungsfehler und über einige damit im Zusammenhange stehende Fragen", Zeitschrift für Mathematik und Physik 21, 1876, S. 102–219
  21. R. L. Plackett, Karl Pearson and the Chi-Squared Test, International Statistical Review, 1983, 61f. See also Jeff Miller, Earliest Known Uses of Some of the Words of Mathematics.

Further reading

  • Lua error in package.lua at line 80: module 'strict' not found.
  • Lua error in package.lua at line 80: module 'strict' not found.

External links