The gamma family has two important branches. The first consists of gamma distributions with integer shape parameter , as you saw in the previous section.
The other important branch consists of gamma distributions that have half-integer shape parameter , that is, when for a positive integer . Notice that this branch contains the one above: every integer is also half of the integer .
18.4.1Chi-Squared ¶
We have already seen the fundamental member of the branch. Let be a standard normal random variable and let . By the change of variable formula for densities, we found the density of to be
That’s the gamma density. It is also called the chi-squared density with 1 degree of freedom, which we will abbreviate to chi-squared (1).
🎥 See More
18.4.2From Chi-Squared to Chi-Squared ¶
When we were establishing the properties of the standard normal density, we discovered that if and are independent standard normal then has the exponential distribution. We saw this by comparing two different settings in which the Rayleigh distribution arises. But that wasn’t a particularly illuminating reason for why should be exponential.
But now we know that the sum of independent gamma variables with the same rate is also gamma; the shape parameter adds up and the rate remains the same. Therefore is a gamma variable. That’s the same distribution as exponential , as you showed in exercises. This explains why the sum of squares of two i.i.d. standard normal variables has the exponential distribution.
If are i.i.d. standard normal variables, then:
has the gamma distribution
has the gamma distribution
has the gamma distribution
Now let be i.i.d. standard normal variables. Then are i.i.d. chi-squared variables. That is, each of them has the gamma distribution.
By induction, has the gamma distribution. This is called the chi-squared distribution with degrees of freedom, which we will abbreviate to chi-squared .
In data science, these distributions often arise when we work with the sum of squares of normal errors. This is usually part of a mean squared error calculation.
18.4.3Chi-Squared Distribution with Degrees of Freedom¶
For a positive integer , the random variable has the chi-squared distribution with degrees of freedom if the distribution of is gamma . That is, has density
Here are the graphs of the chi-squared densities for degrees of freedom 2 through 5.

The chi-squared (2) distribution is exponential because it is the gamma distribution. This distribution has three names:
chi-squared (2)
gamma (1, 1/2)
exponential (1/2)
18.4.4Mean and Variance¶
You know that if has the gamma density then
If has the chi-squared distribution then is gamma . So
Thus the expectation of a chi-squared random variable is its degrees of freedom.
The SD is
18.4.5Estimating the Normal Variance¶
Suppose are i.i.d. normal variables, and that you are in a setting in which you know and are trying to estimate .
Let be in standard units, so that . Define the random variable as follows:
Then has the chi-squared distribution and . Now define by
Then can be computed based on the sample since is known. And since is a linear tranformation of it is easy to see that .
So we have constructed an unbiased estimate of . It is the mean squared deviation from the known population mean.
But typically, is not known. In that case you need a different estimate of since you can’t compute as defined above. You showed in exercises that
is an unbiased estimate of regardless of the distribution of the ’s. When the ’s are normal, as is the case here, it turns out that is a linear transformation of a chi-squared random variable. We will show that later in the course.
18.4.6“Degrees of Freedom”¶
The example above helps explain the strange term “degrees of freedom” for the parameter of the chi-squared distribution.
When is known, you have independent centered normals that you can use to estimate . That is, you have degrees of freedom in constructing your estimate.
When is not known, you are using all of in your estimate, but they are not independent. They are the deviations of the list from their average , and hence their sum is 0. If you know of them, the final one is determined. So you only have degrees of freedom.