FTest in Statistics (original) (raw)

F-Test in Statistics

Last Updated : 8 Apr, 2026

The F-test is a statistical hypothesis testing used to compare the variances of two independent samples. It helps determine whether the variability in two populations is significantly different. The F-test is widely used in hypothesis testing, ANOVA (Analysis of Variance) and statistical model comparison in data science and analytics.

what_is_f_test_

F-Test

To properly understand the F-test, it is important to first understand the F-distribution, since the test statistic follows this distribution.

F-distribution

The F-distribution is a continuous probability distribution that arises as the ratio of two independent chi-square distributed random variables divided by their respective degrees of freedom.

It is defined by two parameters:

**Formula:

F = \frac{(X_1 / df_1)}{(X_2 / df_2)}

**where:

The F-statistic is always greater than or equal to 0 because it is a ratio of variances, and variance cannot be negative.

How the F-Test Works

The F-test compares two variances by forming their ratio. Depending on the research question, the test can be:

The F-test is applicable when:

Hypothesis Testing Framework for F-test

For various hypothesis tests the F test formula is provided as follows:

1. Left Tailed Test

2. Right Tailed Test

3. Two Tailed Test

**F Test Statistics

The F test statistic or simply the F statistic is a value that is compared with the critical value to check if the null hypothesis should be rejected or not. The F test statistic formula is given below:

**For large samples: F_{calc}=\frac{\sigma_{1}^{2}}{\sigma_{2}^{2}}

**For small samples: F_{calc}=\frac{s_{1}^{2}}{s_{2}^{2}}

**where:

Steps to Perform an F-Test

  1. Compute variances of both samples
  2. Define null and alternative hypotheses
  3. Calculate the F statistic
  4. Determine degrees of freedom
  5. Find the critical F value using significance level α
  6. Compare F statistic with critical value

Decision Rule

**Example

Consider the following example In this we conduct a two-tailed F-Test on the following samples:

Statistic Sample 1 Sample 2
Standard Deviation 10.47 8.12
Sample Size 41 21

Step 1: Hypotheses

Step 2: Compute Variances

Step 3: Degrees of Freedom

Step 4: Critical Value

Step 5: Decision

Python Implementation of F-Test

import numpy as np from scipy.stats import f

sample1 = np.random.normal(0, 10.47, 41) sample2 = np.random.normal(0, 8.12, 21)

var1 = np.var(sample1, ddof=1) var2 = np.var(sample2, ddof=1)

f_stat = var1 / var2

df1 = len(sample1) - 1 df2 = len(sample2) - 1

p_value = 2 * min(f.cdf(f_stat, df1, df2), 1 - f.cdf(f_stat, df1, df2))

print(f"F-statistic: {f_stat:.4f}") print(f"P-value: {p_value:.4f}")

`

**Output:

F-statistic: 1.2978
P-value: 0.2697

**Interpretation: Since the p-value > 0.05, we fail to reject the null hypothesis, indicating that the variances are statistically similar.