The F-Test and F-Distribution › The F-Distribution: Where It Comes From

Michael BrenndoerferJanuary 4, 20265 min read
Machine Learning from ScratchAll chapters
Part 2 of 9Hypothesis Testing
Chapter 16The F-Test and F-Distribution › The F-Distribution: Where It Comes From
Reading section 3 of 10 · The F-Distribution: Where It Comes From · 5 minSection 3 of 10 · 5 min

Book contents

Section 3 of 10 · 5 min read

The F-Test and F-Distribution › The F-Distribution: Where It Comes FromOne section · Sections in this chapter3 / 10 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The F-distribution arises naturally when comparing two independent estimates of variance. To understand why, we need to trace through the mathematical foundations.

Building Block: Chi-Squared Distribution

Recall from earlier chapters that when you estimate variance from a sample of nn observations drawn from a normal population with true variance σ2\sigma^2, the quantity:

(n−1)s2σ2∼χn−12\frac{(n-1)s^2}{\sigma^2} \sim \chi^2_{n-1}

follows a chi-squared distribution with n−1n-1 degrees of freedom. This result reflects the fact that s2s^2 is computed from nn observations but loses one degree of freedom because we estimate the mean from the same data.

From Two Samples to the F-Distribution

Now suppose we have two independent samples from populations with variances σ12\sigma_1^2 and σ22\sigma_2^2:

  • Sample 1: n1n_1 observations, sample variance s12s_1^2
  • Sample 2: n2n_2 observations, sample variance s22s_2^2

Each sample variance, properly scaled, follows a chi-squared distribution:

(n1−1)s12σ12∼χn1−12and(n2−1)s22σ22∼χn2−12\frac{(n_1-1)s_1^2}{\sigma_1^2} \sim \chi^2_{n_1-1} \quad \text{and} \quad \frac{(n_2-1)s_2^2}{\sigma_2^2} \sim \chi^2_{n_2-1}

The F-distribution is defined as the ratio of two independent chi-squared random variables, each divided by its degrees of freedom:

F=χ12/df1χ22/df2F = \frac{\chi_1^2 / df_1}{\chi_2^2 / df_2}

Substituting our variance estimates:

F=s12/σ12s22/σ22=s12s22⋅σ22σ12F = \frac{s_1^2 / \sigma_1^2}{s_2^2 / \sigma_2^2} = \frac{s_1^2}{s_2^2} \cdot \frac{\sigma_2^2}{\sigma_1^2}

The Key Simplification Under the Null Hypothesis

Under the null hypothesis that σ12=σ22\sigma_1^2 = \sigma_2^2, the ratio σ22/σ12=1\sigma_2^2 / \sigma_1^2 = 1, which gives us:

F=s12s22∼Fdf1,df2F = \frac{s_1^2}{s_2^2} \sim F_{df_1, df_2}

where df1=n1−1df_1 = n_1 - 1 and df2=n2−1df_2 = n_2 - 1.

The unknown common variance cancels out! This is why the F-test works: we can test whether two population variances are equal without knowing their values. We only need the ratio of the sample variances, and we know its distribution under the null hypothesis.

Properties of the F-Distribution

The F-distribution has distinctive characteristics that set it apart from the normal and t-distributions:

Two degrees of freedom parameters: The F-distribution requires both df1df_1 (numerator) and df2df_2 (denominator). The order matters: F5,10F_{5,10} is a different distribution from F10,5F_{10,5}. This asymmetry reflects the fact that we're comparing a specific numerator variance to a specific denominator variance.

Always non-negative: Since F is a ratio of variances (squared quantities), it cannot be negative. The distribution is defined only for F≥0F \geq 0.

Right-skewed: The F-distribution has a long right tail, especially when degrees of freedom are small. As both df1df_1 and df2df_2 increase, the distribution becomes more symmetric and concentrated.

Mean near 1 under the null: When comparing equal variances, F should be approximately 1. The expected value is E[F]=df2/(df2−2)E[F] = df_2/(df_2 - 2) for df2>2df_2 > 2, which approaches 1 as df2df_2 grows large.

Reciprocal relationship: If F∼Fdf1,df2F \sim F_{df_1, df_2}, then 1/F∼Fdf2,df11/F \sim F_{df_2, df_1}. This is useful for two-tailed tests and for ensuring the larger variance is in the numerator.

Out[2]:
Visualization
Line plot showing F-distributions with varying degrees of freedom parameters.
F-distributions with different degrees of freedom. With small df, the distribution is highly right-skewed with a long tail. As degrees of freedom increase, the distribution becomes more concentrated around 1 and more symmetric. The shape depends on both the numerator (df1) and denominator (df2) degrees of freedom.
Out[3]:
Visualization
F-distribution with shaded right-tail rejection region and critical value marked.
The F-distribution with rejection region for a one-tailed test at alpha = 0.05. Since we typically place the larger variance in the numerator, the test rejects when F is in the right tail. The critical value depends on both degrees of freedom.