Derivation of the Chi-Squared Distribution

Chi-squared is just a gamma in disguise — we prove Z² follows it with 1 degree of freedom and show how sample variance ties in before jumping to the t-distribution.

Alright, chi-squared distribution time.

The chi-squared distribution is just one of the gamma distributions $(\alpha, \lambda)$.

Out of all the gammas out there, the one with $\alpha = n/2$ and $\lambda = 1/2$ — that one specifically gets its own name: the chi-squared distribution with $n$ degrees of freedom.

Recall the gamma:

Equation from the original notes

Plug in $\alpha = n/2$, $\lambda = 1/2$ and you get:

Equation from the original notes

There it is.

And since this is just a gamma in disguise, the MGF, mean, variance — all of it falls out for free.

Equation from the original notes

So the obvious question: if it’s just a gamma, why bother giving it a separate name? Has to be because it’s a little special, right?

Yeah. It is. And the reason is — it’s tied to the normal distribution.

We usually write the random variable for the normal as $Z$, right? And $Z \sim N(0,1)$.

OK but watch this. $Z^2$ follows the chi-squared with 1 degree of freedom. !!!

Equation from the original notes

!!

So given $Z \sim N(0,1)$, let me actually prove that it follows

Equation from the original notes

.

Equation from the original notes

Equation from the original notes

OK. And now that we’ve nailed down that this

Equation from the original notes

follows the chi-squared (which is, again, just a gamma), we get one more thing for free.

Equation from the original notes

For mutually independent standard-normal $Z_1,\ldots,Z_n$, this sum of squares has $n$!!!!!!!!! degrees of freedom — chi-squared, that is. Independence is needed for multiplying the MGFs.

It follows

Equation from the original notes

!!!!

Why?!?!?! Because the chi-squared is a gamma, and we already worked out the additivity of the gamma distribution in a previous post, remember??~~~~~~~~~~

(Gonna use it like, immediately.)

So I’m gonna skip the proof — go check the previous post, it falls right out. heh

OK, one more thing about the chi-squared and then we’re done.

I said the chi-squared matters because it’s connected to $Z$ from the normal. But actually — it has a deep connection with samples too.

And since that connection is gonna be the bridge over to the $t$-distribution, I figured I should lay it down before we move on.

We already talked about the difference between population and sample waaaaaay~~~~~~ back, but let’s revisit.

First, just to pin down notation:

Equation from the original notes

Now that samples are on the table, the population mean and population variance become the things we’re trying to estimate… right…?

Quick aside on that:

Equation from the original notes

Equation from the original notes

Equation from the original notes

When you compute the sample variance

Equation from the original notes

, you all know we divide by $n-1$ instead of $n$ because we burned one degree of freedom.

But! We also figured this out mathematically!!!!!

The whole point was making the expectation of

Equation from the original notes

unbiased.

(Well… it’s kinda the same thing — it only comes out unbiased if you knock the degrees of freedom down by one… heh)

But that wasn’t actually what we were after right now.

What we want to say is — the chi-squared is connected to

Equation from the original notes

….

OK anyway, back to where we were!!!!!

For $n\ge2$ independent observations from the same Gaussian population with $\sigma^2>0$

Equation from the original notes

, and we draw a random sample $X_1, X_2, X_3, \dots, X_n$ of size $n$ from it, and define the sample variance as

Equation from the original notes

,

then "

Equation from the original notes

follows the chi-squared with $n-1$ degrees of freedom."

That’s what we wanted to prove!!!!!!!!!!!!!

Let’s gooooooooooo

Equation from the original notes

Before multiplying MGFs, we need one normal-sample fact: the sample mean is independent of the residual vector $(X_i-\bar X)$. An orthogonal change of coordinates separates the standardized Gaussian vector into its mean direction and $n-1$ perpendicular residual directions; their joint normal density factors. Thus the residual sum $U$ and mean-square term $V$ below are independent. The identity $W=U+V$ alone would not justify $M_W=M_UM_V$!

Equation from the original notes

Done~

↓ Cleaned up nicely on the iPad:

Equation from the original notes

Heads-up. The top half describes a density: $\chi_n^2=\mathrm{Gamma}(n/2,\text{rate }1/2)$, not a positive probability of waiting exactly $x$. The literal $n/2$-th Poisson-arrival interpretation works only when $n/2$ is a positive integer; odd $n$ gives a valid Gamma shape, not a fractional event count. In the even case the process rate is $1/2$ per time unit and the mean waiting time is $n$, not the picture’s loose “in time lambda” wording. The displayed MGF is valid for its argument $t\lt 1/2$.

Equation from the original notes

P.S.

Did you know? I converted all the blog posts into PDFs and offered the PDF materials for sale :-)

Details of the Korean PDF collection are here .

The author’s printed books, “The Physics I’ve Studied” (top) and “The Finance I’ve Studied” (bottom). The handwritten formulas and physical covers are preserved.Open figure at full size

The author’s printed books, “The Physics I’ve Studied” (top) and “The Finance I’ve Studied” (bottom). The handwritten formulas and physical covers are preserved.

Equation from the original notes

n = [1., 2., 3., 4., 5.]
for i in n:
    alpha = i / 2 # i = n
    llambda = 0.5
    scale= 1./llambda
    x = np.linspace(0, 10, 100)
    y = sc.gamma.pdf(x, a=alpha, scale=scale)
    plt.plot(x, y, linewidth=2.0, label = 'n=%s' % i)
plt.grid(True)
plt.legend()
plt.ylabel('p(x)')
plt.xlabel('x')
plt.title(r'$\chi$-squared Distribution')
plt.savefig('4.Chi-squared Distribution.jpeg')

Chi-squared density curves for n=1, 2, 3, 4, and 5


Heads-up. The figures here are the original notes, slips and all. A few things to watch for:

  • On the sheets with $W$, $U$ and $V$, the ratio of moment generating functions is written upside down. It should be $M_U(t)=M_W(t)/M_V(t)$.

Questions or corrections?

Did a step lose you, or does a number look off? Email me or use the contact page. Include the note title and the step or figure you mean.

Feedback goes to me privately by email; it is not posted as a public comment.