Lably
Skip to content

Chi-squared distribution

Probability distribution and special case of gamma distribution

  • 13 min read
  • 6 chapters
  • 1 lab on Lably

Learn it on Lably

The chi-squared distribution χk2 is a special case of the gamma distribution and the univariate Wishart distribution. Specifically if X∼χk2 then X∼Gamma(α=k2,θ=2) (where α is the shape parameter and θ the scale parameter of the gamma distribution) and X∼W1(1,k).

The scaled chi-squared distribution s2χk2 is a reparametrization of the gamma distribution and the univariate Wishart distribution. Specifically if X∼s2χk2 then X∼Gamma(α=k2,θ=2s2) and X∼W1(s2,k).

The chi-squared distribution is one of the most widely used probability distributions in inferential statistics, notably in hypothesis testing and in construction of confidence intervals. This distribution is sometimes called the central chi-squared distribution, a special case of the more general noncentral 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 finding the confidence interval for estimating the population standard deviation of a normal distribution from a sample standard deviation. Many other statistical tests also use this distribution, such as Friedman's analysis of variance by ranks.

Definitions

If Z1, ..., Zk are independent, standard normal random variables, then the sum of their squares, X=∑i=1kZi2, is distributed according to the chi-squared distribution with k degrees of freedom.

This is usually denoted as X∼χ2(k)orX∼χk2.

The chi-squared distribution has one parameter: a positive integer k that specifies the number of degrees of freedom (the number of random variables Zi being summed).

Introduction

The chi-squared distribution is used primarily in hypothesis testing, and to a lesser extent for confidence intervals for population variance when the underlying distribution is normal. Unlike more widely known distributions such as the normal distribution and the exponential distribution, the chi-squared distribution is not as often applied in the direct modeling of 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 for which the chi-squared distribution is extensively used 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.

Suppose that Z is a random variable sampled from the standard normal distribution, where the mean is 0 and the variance is 1: Z∼N(0,1). Now, consider the random variable X=Z2. The distribution of the random variable X is an example of a chi-squared distribution: X∼χ12. 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. 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 turns up as the large sample distribution of generalized likelihood ratio tests (LRT). LRTs have several desirable properties; in particular, simple LRTs commonly provide the highest power to reject the null hypothesis (Neyman–Pearson lemma) and this leads also to optimality properties of generalised LRTs. 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 a small sample size. Similarly, in analyses of contingency tables, the chi-squared approximation will be poor for a small sample size, and it is preferable to use Fisher's exact test. Ramsey shows that the exact binomial test is always more powerful than the normal approximation.

Lancaster 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

χ=m−NpNpq

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

χ2=(m−Np)2Npq

Using N=Np+N(1−p), N=m+(N−m), and q=1−p, this equation can be rewritten as

χ2=(m−Np)2Np+(N−m−Nq)2Nq

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

χ2=∑i=1n(Oi−Ei)2Ei

where

  • χ2 = Pearson's cumulative test statistic, which asymptotically approaches a χ2 distribution;
  • Oi = the number of observations of type i;
  • Ei=Npi = the expected (theoretical) frequency of type i, asserted by the null hypothesis that the fraction of type i in the population is pi; and
  • 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 using the normal distribution directly, or the chi-squared distribution for the normalised, squared difference between observed and expected value. 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 degenerate multivariate normal approximation to the multinomial distribution (the numbers in each category add up to the total sample size, which is considered fixed). Pearson showed that the chi-squared distribution arose from such a multivariate normal approximation to the multinomial distribution, taking careful account of the statistical dependence (negative correlations) between numbers of observations in different categories.

Probability density function

The probability density function (pdf) of the chi-squared distribution is f(x;k)={xk/2−1e−x/22k/2Γ(k2),x>0;0,otherwise. 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.

Cumulative distribution function

Its cumulative distribution function is: F(x;k)=γ(k2,x2)Γ(k2)=P(k2,x2), 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 the simple form: F(x;2)=1−e−x/2 which can be easily derived by integrating f(x;2)=12e−x/2 directly. The integer recurrence of the gamma function makes it easy to compute F(x;k) 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≡x/k, Chernoff bounds on the lower and upper tails of the CDF may be obtained. For the cases when 0<z<1 (which include all of the cases when this CDF is less than half): F(zk;k)≤(ze1−z)k/2.

The tail bound for the cases when z>1, similarly, is 1−F(zk;k)≤(ze1−z)k/2.

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

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Statistics and probability