Dulranga's Notes
Semester 3MathematicsApplied StatisticsDistributions

Chi-Square Distribution

This is a distribution made for analyzing how taken samples from a ZZ distribution (Normal Distribution) is distributed. So we take ZiZ_i values from the distribution and use them to measure how much they vary from the expected.

This is used to see how confident a sample variance to the population variance.

Since ZZ values can be ++ or −-, we use squared sums to avoid cancellations.

chi-square-distribution.png

Interactive - https://www.desmos.com/calculator/wygsiv0nlc

Core Idea

if XX follows a chi-square distribution,

X∼χ2(k)X \sim \chi^2(k)
  • kk - Degree of Freedom

Statistic Definition

if Z1,Z2,…,ZkZ_1, Z_2, \dots, Z_k are independent standard normal random variables where Zi∼N(0,1)Z_i \sim \mathcal{N}(0, 1), the sum of their squares follows a chi-square distribution with kk degrees of freedom.

Q=∑i=1kZi2∼χ2(k)Q = \sum_{i=1}^{k} Z_i^2 \sim \chi^2(k)

For example if we take 10 samples from a normal distribution for one point in the Chi-Square distribution, that has the degree of freedom of 1010. Furthermore, that means each plot point in the Chi-Square is calculated by getting 10 random samples from the normal distribution. (This is the theoretical approach)

Z2=(X−μ)2σ2=(Observed−Expected)2VarianceZ^2 = \frac{(X - \mu)^2}{\sigma^2} = \frac{(\text{Observed} - \text{Expected})^2}{\text{Variance}}

PDF

f(x;k)=12k/2Γ(k2)⋅x(k/2)−1e−x/2f(x; k) = \frac{1}{2^{k/2} \Gamma\left(\frac{k}{2}\right)}\cdot x^{(k/2) - 1} e^{-x/2}
  • kk - No. of DOF
Note

Chi-Square Distribution is a special case of Gamma Distribution. This is equal to, Gamma distribution with α=k/2,β=2\alpha=k/2, \beta=2 i.e. X∼χ2(k)X \sim \chi^2(k), then X∼Gamma(k2,2)X \sim \text{Gamma}(\frac{k}{2}, 2)

Properties

Mean (Expected Value)

E[X]=kE[X] = k
  • Expected value is equal to the degree of freedom.

Variance

V[X]=2⋅kV[X] = 2\cdot k
  • Variance (σ2\sigma^2) is twice the degree of freedom.

Maximum

  • Has a maximum value when DOF is 2 or more.

Chi-Square becomes a normal distribution when DOF increases.

Cumulative Probability

chi-sq-table.png

In practical tables, the distribution is given as cumulative distribution. Also the side it measures is important (left-tailed/right-tailed). If right tailed, shaded area is probability of α\alpha. If left tailed, shaded area is probability of 1−α1-\alpha.

When exact DoFDoF is not in the table

After about DoF = 30, the tables will not show all the DoF values for each. Instead they are shown at intervals such as 30, 40, 50, 60, ... To get an exact χ2\chi^2 value for the intermediate DoF value, we need to do linear interpolation

Example

Assume we can get DoF 6060 and 7070 and we need to find the χ2\chi ^ 2 of DoF=63DoF=63 and Significance level 0.05 In this scenario, DoF=60χ2=40.48DoF = 60 \qquad \chi ^2=40.48 DoF=70χ2=48.76DoF = 70 \qquad \chi ^2=48.76

We linearly interpolate it w.r.t. DoFDoF

\frac{(\chi^2_{63} - \chi^2_{60})}{\left(\chi^2_{70} - \chi^2_{60}\right)} =\frac{63 - 60}{70 - 60}

Practical use with Sample Variance

χ2=(n−1)s2σ2\chi^2 = \frac{(n - 1) s^2}{\sigma^2}
  • ss - Sample variance
  • σ\sigma - hypothesized population variance
  • nn - sample size
Info

If population mean is known, no need to reduce the DoF.

n  s2σ2=∑i=1n(Xi−μσ)2∼χn2\frac{\boxed{n}\;s^2}{\sigma^2}=\sum_{i=1}^{n}\left(\frac{X_i-\mu}{\sigma}\right)^2\sim\chi^2_{n}

This is useful since in real world we almost never know the true population variance or it is costly to find.

Note

The sample variance ss is calculated with the correction factor n−1n-1

s2=∑(xi−xˉ)2n−1s^2 = \frac{\sum (x_i - \bar{x})^2}{n - 1}

So to cancel it out and get the theoretical formula for the Chi-Square distribution, we use n−1n-1 in the numerator.

(n−1)s2=(n−1)[∑i=1n(Xi−Xˉ)2n−1]=∑i=1n(Xi−Xˉ)2(n - 1) s^2 = (n - 1) \left[ \frac{\sum_{i=1}^{n} (X_i - \bar{X})^2}{n - 1} \right] = \sum_{i=1}^{n} (X_i - \bar{X})^2

Substituting this back into the formula yields:

(n−1)s2σ2=∑i=1n(Xi−Xˉσ)2\frac{(n - 1) s^2}{\sigma^2} = \sum_{i=1}^{n} \left(\frac{X_i - \bar{X}}{\sigma}\right)^2

Hypothesis testing

chi-square-variance-tails.png

On this page