# 17.3.6.2 Algorithms (Two Sample Test for Variance)

The F-test calculates the ratio of two sample variance to test whether or not the two data samples come from populations with equal variances. And the hypotheses take the form:

$H_0:\frac{\sigma_1^2}{\sigma_2^2}=1$ vs $H_1:\frac{\sigma_1^2}{\sigma_2^2}\ne 1$ Two Tailed

$H_0:\frac{\sigma_1^2}{\sigma_2^2} \le 1$ vs $H_1:\frac{\sigma_1^2}{\sigma_2^2} > 1$ Upper tailed

$H_0:\frac{\sigma_1^2}{\sigma_2^2} \ge 1$ vs $H_1:\frac{\sigma_1^2}{\sigma_2^2} < 1$ Lower tailed

### Test Statistics

And the F-test statistic is calculated as: $F=\frac{s_1^2}{s_2^2}$

where $s_1^2\,\!$ and $s_2^2\,\!$ are observed sample variances. A ratio of 1 implies equal sample variances, while ratios that deviate from 1 indicate unequal population variances. The hypothesis that the variances of the two samples are equal is rejected if $p < \sigma\,\!$, where p is the calculated probability and $\sigma\,\!$ is the chosen significance level.

### Confidence Intervals

The upper and lower confidence limit values for F-test statistic is:

Null Hypothesis Confidence Interval
$H_0:\frac{\sigma_1^2}{\sigma_2^2}=1$ $\left[\frac{F}{F_{1-\alpha/2}},\frac{F}{F_{\alpha/2}}\right]$
$H_0:\frac{\sigma_1^2}{\sigma_2^2} \le 1$ $\left[\frac{F}{F_{1-\alpha}},\infty\right]$
$H_0:\frac{\sigma_1^2}{\sigma_2^2} \ge 1$ $\left[0,\frac{F}{F_{\alpha}}\right]$

where $F_{1-\sigma/2}\,\!$ and $F_{\sigma/2}\,\!$ represents the lower and upper critical values for an F-distribution with $n_1-1\,\!$ and $n_2-1\,\!$ degrees of freedom, and $\sigma\,\!$ level of significance.