Estimate how many observations you need so that the chi-square confidence interval for the variance has a maximum relative width, for a fixed confidence level.
Calculator
Enter the maximum tolerable U/L ratio of the CI and the confidence level to get the minimum sample size.
Maximum tolerable ratio between the upper and lower bounds of the CI for the variance. The closer to 1, the narrower (more precise) the interval, but the larger the sample needed. R between 2 and 4 is common in quality control.
Probability that the procedure produces an interval containing the true variance. 95% is the standard; with 99% a larger sample is needed for the same ratio R.
Explanation
The confidence interval for the variance \(\sigma^2\) uses the chi-square distribution and has the form:
\( \left[\frac{(n-1)s^2}{\chi^2_{1-\alpha/2,\,n-1}},\;\; \frac{(n-1)s^2}{\chi^2_{\alpha/2,\,n-1}}\right] \)
Unlike CIs for means or proportions, the absolute width of the CI for the variance depends on the unknown value of \(\sigma^2\), which makes it impossible to express precision in absolute units without knowing it beforehand. The natural solution is to specify precision in relative terms: the U/L ratio between the upper and lower limits of the CI.
This ratio depends only on the quantiles of the chi-square distribution, and therefore only on the sample size \(n\) and the confidence level. No assumption about \(\sigma^2\) is needed.
Formula for the U/L ratio
\( \frac{U}{L} = \frac{\chi^2_{1-\alpha/2,\,n-1}}{\chi^2_{\alpha/2,\,n-1}} \)
For a given confidence level and a desired ratio \(R\), the calculator searches for the smallest \(n\) such that \(\chi^2_{1-\alpha/2,\,n-1}/\chi^2_{\alpha/2,\,n-1} \leq R\). There is no closed-form formula: the result is obtained by an iterative search over \(n\).
- R close to 1: very narrow CI → enormous sample.
- R = 2: the upper limit doubles the lower limit → reasonable sample (≈ 65 observations at 95%).
- R = 3: the upper limit triples the lower limit → much smaller sample (≈ 28 observations at 95%).
Interpreting the U/L ratio
A ratio \(R = 2.5\) means the upper limit of the CI can be up to 2.5 times larger than the lower limit. For example, if \(s^2 = 4.0\), the CI could go from 2.5 to 6.25 (a variability of 2.5 to 1 between the extremes). The smaller \(R\) is, the narrower and more informative the CI, but the more observations are needed.
Quick setup
- Ratio R: R between 2 and 4 is common in quality control and process studies. R very close to 1 requires prohibitively large samples.
- Confidence level: 95% is the standard. With 99% the required n is significantly larger for the same R.
- Normality: make sure the data are compatible with normality; the chi-square CI is very sensitive to this assumption.
- Expected losses: divide n by (1 − dropout rate) to get the number of subjects to recruit.
Worked example
A metrology laboratory wants to estimate the variance of a measurement instrument's error to validate its calibration. It is established that the 95% CI must have a U/L ratio no greater than \(R = 2.5\) (the upper limit cannot be more than 2.5 times the lower limit).
The calculator searches for the smallest \(n\) such that \(\chi^2_{0.975,\,n-1} / \chi^2_{0.025,\,n-1} \leq 2.5\). For \(n = 39\) (df = 38): \(\chi^2_{0.975,38} \approx 56.90\) and \(\chi^2_{0.025,38} \approx 22.88\), ratio \(\approx 2.49 \leq 2.5\). For \(n = 38\): ratio \(\approx 2.52 > 2.5\). Result: \(n = 39\) observations.
With those 39 measurements, if \(s = 0.12\) mm (variance \(s^2 = 0.0144\) mm²), the 95% CI would be approximately... more precisely, using the exact quantiles: \([(38 \times 0.0144)/56.90,\; (38 \times 0.0144)/22.88] = [0.0096,\; 0.0239]\) mm². The actual U/L ratio is \(0.0239/0.0096 \approx 2.49\).
Sensitivity analysis: if the laboratory accepts \(R = 3\) (the upper limit can triple the lower limit), the sample shrinks to \(n = 28\). With \(R = 2\) the sample rises to \(n \approx 65\). The choice of \(R\) has a very large impact on the required n.
Model assumptions
- The variable of interest follows a normal distribution. The chi-square CI for the variance is very sensitive to non-normality, more so than any CI for the mean.
- Observations are independent of each other.
- The target U/L ratio must be greater than 1; the iterative search starts at \(n = 2\).
Common uses
- Statistical process control (SPC): estimating the process variance for control charts.
- Validation of measurement instruments and reproducibility studies.
- Design of experiments where variability is the main variable of interest.
- Auditing of production processes where dispersion needs to be characterized.
How to interpret the result
The value \(n\) guarantees that the confidence interval for \(\sigma^2\) based on the chi-square distribution will have a ratio between the upper and lower limits no greater than the specified value \(R\), at the chosen confidence level. This ensures relative precision: the upper limit of the CI will not exceed \(R\) times the lower limit. Always round up. If you expect losses or exclusions during data collection, divide \(n\) by \((1 - \text{dropout rate})\); with a 10% dropout rate, recruit \(\lceil n / 0.90 \rceil\) units.
The most critical and delicate assumption of this method is the normality of the data: the chi-square CI for \(\sigma^2\) is very sensitive to deviations from normality, much more so than the CI for the mean. With skewed or heavy-tailed distributions, the actual CI can have coverage well below the nominal level (e.g., a 95% CI may cover the true \(\sigma^2\) only 85% of the time). Before applying this result, check normality with the Shapiro-Wilk test or with Q-Q plots. Sensitivity to \(R\): requiring a ratio \(R = 2\) (narrow CI) requires many more subjects than \(R = 4\) (wide CI); increasing \(R\) by 50% can cut \(n\) in half.
If the calculated \(n\) is not feasible, the alternatives are: (1) accept a larger ratio \(R\) (wider CI), (2) reduce the confidence level (e.g., from 99% to 95%), or (3) if the data are not normal, use bootstrap methods to build the CI for \(\sigma^2\) without relying on the chi-square distribution. Once the data are collected, build the actual CI with the CI calculator for the variance; if you also want to test \(\sigma^2\) against a reference value, use the sample size calculator for a one-variance test.
References and further reading
- Zar, J. H. (2010). Biostatistical Analysis (5th ed.). Pearson. — sample size calculation for variance.
- Montgomery, D. C. (2019). Introduction to Statistical Quality Control (8th ed.). Wiley. — applications in SPC.
- Wikipedia (en): Chi-squared distribution — properties and percentiles.
Frequently asked questions
- Why do I need such a large sample for a narrow variance CI? Because the chi-square distribution converges slowly to symmetry. With few degrees of freedom, the extreme quantiles are far apart, producing very asymmetric and wide CIs.
- What happens if the data aren't normal? The chi-square CI can have actual coverage very different from the nominal confidence level. First apply a normality test (Shapiro-Wilk) and, if the data aren't normal, consider transformations or bootstrap methods.
- Can I use this result if I want to estimate σ instead of σ²? Yes. The CI for σ is obtained by taking the square root of each limit of the σ² CI, and the U/L ratio is the same.