Sample size for a 2-variances test (F test)

Updated

Sample size for a 2-variances test is the number of units per group needed so that a 2-variances test detects a given ratio between two standard deviations with a chosen power. For normal data the ratio of sample variances follows an F distribution, so the power of the F test can be computed exactly. Expect large samples: detecting that one process varies 50% more than another takes about 50 units from each.

When to use it

  • You suspect one machine, cavity, supplier or operator produces more variation than another and want a fair test.
  • You are qualifying a second source and need to show its variation is not larger.
  • You want to know whether an already-planned comparison of means will also say something useful about variation.

How it works

With n₁ and n₂ units, the test statistic is F = s₁²/s₂². When σ₁ = σ₂ it follows an F distribution with n₁ − 1 and n₂ − 1 degrees of freedom. If the true ratio of standard deviations is ρ = σ₁/σ₂, then F/ρ² has that same F distribution, which gives the two-sided power directly:

Power = P( F′ > F₁₋α/₂ / ρ² ) + P( F′ < Fα/₂ / ρ² ), F′ ~ F(n₁ − 1, n₂ − 1)

Search for the smallest n (per group, with n₁ = n₂ = n) that reaches the target power. For a one-sided test, keep only the tail in the direction of interest with α in place of α/2.

A normal approximation on the log scale gives a starting value:

n ≈ 1 + ( (z₁₋α/₂ + z₁₋β) / ln ρ )²

This sizes the classic F test, which assumes both groups are normal. Tests that are more robust to non-normality, such as Levene's or Bonett's, have somewhat lower power for normal data; size them by simulation if you plan to use them.

Example

Two injection molding machines make the same housing. Wall thickness from machine 2 looks more variable, and a standard deviation 1.5 times that of machine 1 would justify moving the part. The plan: a two-sided F test at α = 0.05 with 80% power to detect ρ = 1.5.

  • Approximation: 1 + ((1.960 + 0.842) / ln 1.5)² = 48.7, so 49 parts per machine. Exact power with 49 is 0.794.
  • Exact F: 50 parts per machine give power 0.802, 100 parts in all.

With 50 per group, F₀.₉₇₅,₄₉,₄₉ = 1.762 and F₀.₀₂₅,₄₉,₄₉ = 0.567, so the test declares a difference when s₂/s₁ is above √1.762 = 1.33 or below √0.567 = 0.75. A simulation of 200,000 pairs of samples of 50 with σ₂/σ₁ = 1.5 (NumPy, seed 8) rejected in 80.3% of the pairs.

If only the direction "machine 2 varies more" matters, a one-sided test needs 40 parts per machine for the same power. To detect a smaller ratio of 1.25, the two-sided test needs 160 per machine.

Power of a two-sided F test for two variances, α = 0.050.000.250.500.751.00Powern = 10 per groupn = 20 per groupn = 50 per groupn = 80 per group1.01.251.51.752.02.5True ratio of standard deviations σ₂/σ₁
Power of a two-sided F test for two variances, α = 0.05

How to read the results

  • Fifty parts per machine give an 80% chance of detecting a 1.5 ratio.
  • Ten parts per group are nearly useless for variation. Even a doubling of σ is detected only half the time.
  • The F test is about the ratio, not the difference. A shift of 0.01 mm in σ matters more for a tight process than for a loose one, and the calculation reflects that.
  • Combine with the means. If you also compare means, the same 50 parts per machine give a 2-sample t test 84% power to detect a mean shift of 0.6σ.

Common mistakes

  • Using the F test on non-normal data. Its false alarm rate can be far off with skewed or heavy-tailed data. Check each group's distribution, or use a robust test such as the one in test for equal variances.
  • Comparing groups with different time spans. Fifty parts from one hour on machine 1 against fifty from a week on machine 2 compare short-term with long-term variation.
  • Letting the mean difference leak in. Compute each group's standard deviation around its own mean. Pooling the two groups first inflates the variation.
  • Stopping at "not significant". With small samples, a non-significant F test is weak evidence of equal variation.

Frequently asked questions

Why is the F test so sensitive to non-normality?

Its null distribution relies on the fourth moment (the tails) of the normal distribution. With heavier tails, sample variances vary more than the F distribution assumes, so the test rejects too often.

Can the groups have different sizes?

Yes. The F distribution then has n₁ − 1 and n₂ − 1 degrees of freedom. For a fixed total, equal sizes give the most power.

What about more than two groups?

Use a test for equal variances across all groups, such as Levene's or Bartlett's test. Their sample size is usually found by simulation.

How does this relate to the 1-variance test?

A 1-variance test compares one group with a fixed σ₀ known without error. Here both standard deviations are estimated, which is why each group needs more units: a two-sided 1-variance test reaches 80% power for a ratio of 1.5 with 24 units, against 50 per group here.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab