Tutorials › Statistical Theory I - Probability and Distribution Theory › Degrees of Freedom and Sample Variance Conventions

Exact Sampling Distributions · Tutorial 774 of 994

Degrees of Freedom and Sample Variance Conventions

Learn how the residual chi-square law determines the exact distributions and moment properties of variance estimates using divisors \(n-1\) and \(n\).

Advanced 11 min read

What You'll Learn

  • Identify the residual sum of squares and its degrees of freedom in a normal sample.
  • Translate its chi-square law into distributions for both variance conventions.
  • Relate the divisor-\(n\) and divisor-\(n-1\) estimators exactly.
  • Derive their expectations and variances under normal sampling.
  • Calculate probabilities by translating variance-estimator events to chi-square events.

Why Two Variance Conventions Arise

For a sample of \(n\) observations, two familiar quantities are both called sample variance. One divides the residual sum of squares by \(n-1\); the other divides it by \(n\). The difference is not merely a naming convention: it changes the exact distribution and the expectation of the estimate. The degrees of freedom in the residual sum of squares, however, remain \(n-1\) under either convention.

The key is to begin with the normal-sample residual sum of squares and then apply the chosen divisor. This tutorial makes that translation explicit. Throughout, assume \(X_1,\ldots,X_n\) are independent and identically distributed as \(N(\mu,\sigma^2)\), with \(\sigma^2>0\) and \(n\geq 2\), and let \(\bar X=n^{-1}\sum_{i=1}^n X_i\).

Definition: The residual sum of squares is \(Q=\sum_{i=1}^n (X_i-\bar X)^2\). The divisor-\((n-1)\) sample variance is \(S^2=Q/(n-1)\). The divisor-\(n\) variance is \(V_n=Q/n\). Thus \(S^2\) and \(V_n\) use the same residuals but different divisors.

The Residual Chi-Square Law

The normal-sample residual result gives the starting distribution. In geometric terms, centering removes the component of the sample vector in the direction of the all-ones vector. The residual vector lies in a subspace of dimension \(n-1\), which accounts for the degrees of freedom.

Theorem: If \(X_1,\ldots,X_n\) are independent \(N(\mu,\sigma^2)\) random variables with \(\sigma^2>0\), then \[ \frac{Q}{\sigma^2}=\frac{\sum_{i=1}^n(X_i-\bar X)^2}{\sigma^2}\sim\chi^2_{n-1}. \] Here \(\chi^2_\nu\) denotes the chi-square distribution with \(\nu\) degrees of freedom. In particular, the unknown mean \(\mu\) does not appear in this residual-sum-of-squares distribution.

This result concerns \(Q/\sigma^2\), not \(Q\) itself: \(Q\) has the scale \(\sigma^2\). The two variance conventions follow by dividing the same equality by different constants.

Theorem: Under the same assumptions, with \(n\geq2\), \[ \frac{(n-1)S^2}{\sigma^2}\sim\chi^2_{n-1}, \qquad \frac{nV_n}{\sigma^2}\sim\chi^2_{n-1}. \] Equivalently, \(S^2\) has the distribution of \(\sigma^2/(n-1)\) times a \(\chi^2_{n-1}\) random variable, while \(V_n\) has the distribution of \(\sigma^2/n\) times a \(\chi^2_{n-1}\) random variable.

The degrees of freedom do not change when the divisor changes. Dividing by \(n\) changes the scale of the random variable, not the dimension of the residual subspace.

Deriving the Two Distributions

Write \(\nu=n-1\) and \(U=Q/\sigma^2\), so that \(U\sim\chi^2_\nu\). By definition, \(S^2=\sigma^2 U/\nu\) and \(V_n=\sigma^2 U/n\). These identities prove the scaled chi-square statements directly. They also yield density formulas if a density, rather than a scaled-distribution representation, is needed.

The chi-square density is \[ f_U(u)=\frac{u^{\nu/2-1}e^{-u/2}}{2^{\nu/2}\Gamma(\nu/2)},\qquad u>0, \] where \(\Gamma\) is the gamma function. For \(s>0\), the change of variable \(u=\nu s/\sigma^2\) has derivative \(du/ds=\nu/\sigma^2\). Therefore

$$ f_{S^2}(s)= \frac{(\nu/(2\sigma^2))^{\nu/2}}{\Gamma(\nu/2)} s^{\nu/2-1}\exp\!\left(-\frac{\nu s}{2\sigma^2}\right), \qquad s>0. $$

For \(V_n\), use \(u=nv/\sigma^2\), with derivative \(du/dv=n/\sigma^2\). This gives

$$ f_{V_n}(v)= \frac{(n/(2\sigma^2))^{\nu/2}}{\Gamma(\nu/2)} v^{\nu/2-1}\exp\!\left(-\frac{nv}{2\sigma^2}\right), \qquad v>0. $$

Both densities have the same power \(v^{\nu/2-1}\) or \(s^{\nu/2-1}\), reflecting the same degrees of freedom. Their exponential terms and leading constants differ because their scales differ.

Worked Example: Translating a Tail Event Correctly

Suppose \(X_1,\ldots,X_5\) are independent \(N(\mu,1)\) observations. Find \(P(S^2>8)\) in terms of an exact chi-square tail probability, and simplify it.

Here \(n-1=4\), so \(Q\sim\chi^2_4\) because \(\sigma^2=1\), and \(S^2=Q/4\). Thus

$$ S^2>8 \quad\Longleftrightarrow\quad \frac{Q}{4}>8 \quad\Longleftrightarrow\quad Q>32. $$

Consequently \(P(S^2>8)=P(\chi^2_4>32)\). For four degrees of freedom, the chi-square survival probability at \(x\geq0\) is \(e^{-x/2}(1+x/2)\). Substituting \(x=32\) gives

$$ P(S^2>8)=e^{-16}(1+16)=17e^{-16}\approx 1.91\times10^{-6}. $$

The threshold must be multiplied by \(4\), not divided by \(4\), when translating from \(S^2=Q/4\) to an event about \(Q\).

Relationship, Bias, and Variability

The two variance estimates are deterministically related for every observed sample:

$$ V_n=\frac{n-1}{n}S^2 \qquad\text{and}\qquad S^2=\frac{n}{n-1}V_n. $$

To derive their moments, first recall the moments of a chi-square variable. If \(U\sim\chi^2_\nu\), its moment-generating function is \(M_U(t)=(1-2t)^{-\nu/2}\) for \(t<1/2\). This follows by writing \(U\) as a sum of squares of \(\nu\) independent standard normal variables: for \(Z\sim N(0,1)\), direct integration of the normal density gives \(E[e^{tZ^2}]=(1-2t)^{-1/2}\), and independence multiplies these factors. Differentiating the moment-generating function at zero gives

$$ E[U]=M_U'(0)=\nu, \qquad \operatorname{Var}(U)=M_U''(0)-\{M_U'(0)\}^2 =\nu(\nu+2)-\nu^2=2\nu. $$

Since \(S^2=\sigma^2 U/\nu\), multiplying the mean by \(\sigma^2/\nu\) and the variance by \((\sigma^2/\nu)^2\) yields \(E[S^2]=\sigma^2\) and \(\operatorname{Var}(S^2)=2\sigma^4/\nu\). Since \(V_n=\sigma^2 U/n\), the corresponding calculations give

Result: For an independent normal sample with \(n\geq2\), \[ E[S^2]=\sigma^2,\qquad \operatorname{Var}(S^2)=\frac{2\sigma^4}{n-1}, \] \[ E[V_n]=\frac{n-1}{n}\sigma^2,\qquad \operatorname{Var}(V_n)=\frac{2(n-1)\sigma^4}{n^2}. \] Thus \(S^2\) is unbiased for \(\sigma^2\), whereas \(V_n\) has downward bias \(-\sigma^2/n\).

The unbiasedness of \(S^2\) does not mean that every sample estimate equals \(\sigma^2\); it means that its expectation over repeated samples equals \(\sigma^2\). The divisor-\(n\) version is smaller for every sample with \(Q>0\), and its expected value is correspondingly smaller. In the normal model with \(\mu\) unknown, \(V_n\) is also the maximum likelihood estimator of \(\sigma^2\); that fact does not make it unbiased.

Worked Example: Comparing the Two Estimators’ Moments

Let \(n=8\) and suppose the observations are independent \(N(\mu,9)\). Find the expectation and variance of each variance estimate, and express both in terms of a chi-square variable.

Here \(\sigma^2=9\), \(\sigma^4=81\), and \(\nu=n-1=7\). If \(U\sim\chi^2_7\), then

$$ S^2=\frac{9}{7}U, \qquad V_n=\frac{9}{8}U. $$

Using \(E[U]=7\) and \(\operatorname{Var}(U)=14\),

$$ E[S^2]=\frac{9}{7}\cdot7=9, \qquad \operatorname{Var}(S^2)=\left(\frac{9}{7}\right)^2\cdot14 =\frac{162}{7}. $$

For the divisor-\(n\) estimate,

$$ E[V_n]=\frac{9}{8}\cdot7=\frac{63}{8}=7.875, \qquad \operatorname{Var}(V_n)=\left(\frac{9}{8}\right)^2\cdot14 =\frac{567}{32}=17.71875. $$

The expectation of \(V_n\) is \(7/8\) of the true variance, matching \(E[V_n]=(n-1)\sigma^2/n\). Also \(V_n=(7/8)S^2\), so its variance is \((7/8)^2\operatorname{Var}(S^2)\), which gives \((49/64)(162/7)=567/32\), confirming the calculation.

Worked Example: Using the Divisor-n Distribution

Suppose \(X_1,X_2,X_3\) are independent \(N(\mu,4)\) observations. Find \(P(V_n\leq 4/3)\).

Now \(n=3\), \(\sigma^2=4\), and \(Q/4\sim\chi^2_2\). Since \(V_n=Q/3\), the event becomes

$$ V_n\leq\frac{4}{3} \quad\Longleftrightarrow\quad \frac{Q}{3}\leq\frac{4}{3} \quad\Longleftrightarrow\quad Q\leq4 \quad\Longleftrightarrow\quad \frac{Q}{4}\leq1. $$

A \(\chi^2_2\) variable has distribution function \(P(\chi^2_2\leq x)=1-e^{-x/2}\) for \(x\geq0\). Therefore

$$ P(V_n\leq4/3)=P(\chi^2_2\leq1)=1-e^{-1/2}\approx0.3935. $$

This calculation uses the variance \(\sigma^2=4\) in the scaling. Omitting it would give the wrong chi-square threshold.

Degrees of Freedom and Common Mistakes

One degree of freedom is used in estimating the common mean through \(\bar X\). The \(n\) deviations \(X_i-\bar X\) satisfy \(\sum_{i=1}^n(X_i-\bar X)=0\), so they cannot vary independently across all \(n\) coordinates. This constraint leaves \(n-1\) residual directions. Choosing a different divisor for their squared length does not restore the missing direction.

  • Changing the divisor and changing the degrees of freedom are not the same operation. Both \(S^2\) and \(V_n\) are scaled versions of a chi-square variable with \(n-1\) degrees of freedom.
  • Do not reverse an event inequality while scaling by a positive constant. From \(S^2=Q/(n-1)\), the event \(S^2>c\) is \(Q>(n-1)c\), not \(Q>c/(n-1)\).
  • Do not call both quantities unbiased. Under the stated normal model, \(E[S^2]=\sigma^2\), while \(E[V_n]=(n-1)\sigma^2/n\).

For \(n=1\), there are no residual degrees of freedom: \(Q=0\) and the divisor-\((n-1)\) variance is undefined. The results for \(S^2\) therefore require \(n\geq2\), as assumed throughout.

Key takeaway: Start with \(Q/\sigma^2\sim\chi^2_{n-1}\). Then \(S^2=Q/(n-1)\) and \(V_n=Q/n\) have the same \(n-1\) degrees of freedom but different scales. The first is unbiased for \(\sigma^2\); the second is smaller by the exact factor \((n-1)/n\).

Check Your Understanding

Use the residual chi-square law to answer each question, keeping the scale and degrees of freedom distinct.

  1. For an independent \(N(\mu,\sigma^2)\) sample of size \(n\), what is the distribution of \((n-1)S^2/\sigma^2\)?
  2. For \(n=6\), write \(V_n\) as a scaled chi-square random variable and state its degrees of freedom.
  3. If \(S^2=Q/5\), translate the event \(S^2>3\) into an event involving \(Q\).
  4. Which estimator is unbiased for \(\sigma^2\), and what is the expectation of the other?
  5. Why does using divisor \(n\) rather than \(n-1\) not change the degrees of freedom?