Skip to content

ADescribe · Guide test 091

F test for two variances

Tests a ratio of variances using independent normal samples.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

In Equal spread tests, choose Test = F test for two variances.

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · F test for two variances

20
20
0.00
1.0
1.7
0.050

Alternative

Your data

Drag a point or use ↑/↓ to change it
Group 1 · n = 20 · mean 0.10Group 2 · n = 20 · mean 0.30

If H₀ were true

F = 0.40
  1. The reference: how F varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .051).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

F=s12s22,ν1=n1−1, ν2=n2−1F = \dfrac{s_1^2}{s_2^2},\qquad \nu_1 = n_1-1,\ \nu_2 = n_2-1

With your numbers

F=1.2922.052=0.40F = \dfrac{1.29^2}{2.05^2} = 0.40
sj2s_j^2
sample variances
ν1, ν2\nu_1,\ \nu_2
numerator and denominator degrees of freedom

The verdict

F(19, 19) = 0.40, p = .051, s₁²/s₂² = 0.40

p > α = .050: compatible with H₀

Effect size: variance ratio s₁²/s₂² = 0.398

Exact for normal data but notoriously non-robust: skewed or heavy-tailed data make it reject far too often. Prefer Brown–Forsythe or Fligner–Killeen.

Statistic
0.398
p-value
0.0512
F test for two variances on Group 1: n = 20; Group 2: n = 20: F(19, 19) = 0.40, p = .051, s1²/s2² = 0.40. The p-value is above α = .050, so the data are compatible with H0.

F test for two variances on Group 1: n = 20; Group 2: n = 20: F(19, 19) = 0.40, p = .051, s₁²/s₂² = 0.40. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: σ1²/σ2²=r0, usually r0=1.

Assumptions

Independent normal samples and independent observations within each sample.

Formula

F=s12/s22r0∼Fn1−1,n2−1F=\frac{s_1^2/s_2^2}{r_0}\sim F_{n_1-1,n_2-1}

Parameters and notation

s1²,s2² are unbiased sample variances; n1,n2 sample sizes.

Structure of the method

Calculate independent unbiased sample variances, divide their ratio by the prespecified null ratio, and use an F distribution with the two residual degrees of freedom. The direction depends on which sample is placed in the numerator; a two-sided convention must account for the asymmetric reference.

Estimated and nuisance parameters

Estimate a separate mean and variance in each sample. The null variance ratio is a design target, while the common overall variance scale cancels from the statistic. Sample sizes determine numerator and denominator degrees of freedom; equal group sizes are unnecessary.

Settings and design choices

Fix numerator group, null ratio, alternative, confidence level, and missing-data policy. Do not automatically move the larger sample variance into the numerator while keeping an unchanged one-sided hypothesis. The conventional twice-smaller-tail rule should be named when comparing implementations.

Fitting and adaptation

Re-estimate both variances for new independent groups. A normal-null simulation can preserve each group size and impose the target variance ratio. No fine-tuning applies. Paired measurements need a paired variance procedure rather than treating matched rows as independent samples.

Sensitivity and robustness

The F reference is very sensitive to heavy tails and skewness. A preliminary F test used to choose between pooled and Welch mean tests can distort the overall decision procedure. Small samples and near-zero denominator variance create wide or unstable ratio inference.

How to use and calibrate

Use the chosen F tail or twice the smaller tail for a conventional two sided test.

Example application

Compare precision of two instruments under a normal measurement model.

Interpretation and pitfalls

Watch out

F variance tests are very nonrobust to heavy tails and skew. Do not automatically use them to decide between pooled and Welch t tests.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Normal independent groups; sensitive to nonnormality.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x = np.array([4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0])
y = np.array([4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9])
F=x.var(ddof=1)/y.var(ddof=1);a=len(x)-1;b=len(y)-1
print(F,min(1,2*min(stats.f.cdf(F,a,b),stats.f.sf(F,a,b))))
Output
2.6153846153846145 0.16828289820810474
R

Validated — Executed successfully in the validation environment · needs Base/standard library

x <- c(4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0)
y <- c(4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9)
print(var.test(x,y))
Output
	F test to compare two variances

data:  x and y
F = 2.6154, num df = 9, denom df = 9, p-value = 0.1683
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
  0.6496245 10.5295232
sample estimates:
ratio of variances 
          2.615385

Sources

Statistics guide v4 (historical):
R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 091, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT091.