StatsCalculators.com

F Distribution

Created:October 18, 2024
Last Updated:May 2, 2025

This calculator helps you compute the probabilities of an F distribution given the degrees of freedom parameters for the numerator and denominator. You can find the probability of values being less than, greater than, or between specific values. The distribution chart shows the probability density function (PDF) of the F distribution, which is widely used for hypothesis testing in analysis of variance (ANOVA), comparing variances, and testing the significance of regression models.

Calculator

Parameters

Interactive Distribution Chart

Click Calculate to view the distribution chart

Related Calculators

Learn More

F Distribution: Definition, Formula, and Applications

F Distribution

Definition: The F distribution (also known as Fisher-Snedecor distribution) is a continuous probability distribution used to compare variances and test hypotheses in analysis of variance (ANOVA). It is the ratio of two chi-square distributions divided by their respective degrees of freedom.

Formula:The probability density function (PDF) is given by:f(x;d1,d2)=1B(d12,d22)(d1d2)d1/2xd1/21(1+d1d2x)(d1+d2)/2f(x; d_1, d_2) = \frac{1}{\text{B}(\frac{d_1}{2}, \frac{d_2}{2})} \left(\frac{d_1}{d_2}\right)^{d_1/2} x^{d_1/2-1}\left(1 + \frac{d_1}{d_2}x\right)^{-(d_1+d_2)/2}where:B(a,b)=Γ(a)Γ(b)Γ(a+b)\text{B}(a,b) = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}is the beta function, and the parameters are:
  • d1d_1 is the degrees of freedom for numerator
  • d2d_2 is the degrees of freedom for denominator
  • Γ\Gamma is the gamma function

Properties

Key Statistics:

  • Mean: E(X)=d2d22E(X) = \frac{d_2}{d_2-2} for d2>2d_2 > 2
  • Variance: Var(X)=2d22(d1+d22)d1(d22)2(d24)\text{Var}(X) = \frac{2d_2^2(d_1+d_2-2)}{d_1(d_2-2)^2(d_2-4)} for d2>4d_2 > 4
  • Mode: d12d1d2d2+2\frac{d_1-2}{d_1} \cdot \frac{d_2}{d_2+2} for d1>2d_1 > 2

Key Properties:

  • Always non-negative (defined for x ≥ 0)
  • Right-skewed distribution
  • Approaches normal distribution for large degrees of freedom
  • Related to ratio of chi-square distributions

How to Calculate F Distribution in R

R
library(tidyverse)

# Parameters
df1 <- 4  # numerator degrees of freedom
df2 <- 10 # denominator degrees of freedom

# Calculate probability between two values
x1 <- 0.5
x2 <- 2.5
prob <- pf(x2, df1 = df1, df2 = df2) - pf(x1, df1 = df1, df2 = df2)
print(str_glue("P({x1} < X < {x2}) = {round(prob, 4)}")) # P(0.5 < X < 2.5) = 0.6274

# Calculate probability density at x1
density_at_x1 <- df(x1, df1 = df1, df2 = df2)
print(str_glue("f({x1}) = {round(density_at_x1, 4)}")) # f(0.5) = 0.6698

# Calculate cumulative probability at x1
cdf_at_x1 <- pf(x1, df1 = df1, df2 = df2)
print(str_glue("P(X ≤ {x1}) = {round(cdf_at_x1, 4)}")) # P(X ≤ 0.5) = 0.2632

# mean and variance
if(df2 > 2) {
  mean_f <- df2 / (df2 - 2)
  print(str_glue("Mean: {round(mean_f, 4)}")) # Mean: 1.25
} else {
  print(str_glue("Mean is undefined (df2 must be > 2)"))
}

if(df2 > 4) {
  var_f <- (2 * df2^2 * (df1 + df2 - 2)) / (df1 * (df2 - 2)^2 * (df2 - 4))
  print(str_glue("Variance: {round(var_f, 4)}")) # Variance: 1.5625
} else {
  print(str_glue("Variance is undefined (df2 must be > 4)"))
}

# Create plot
x <- seq(0, 5, length.out = 1000)
y <- df(x, df1 = df1, df2 = df2)
df <- tibble(x = x, y = y)

ggplot(df, aes(x = x, y = y)) +
  geom_line(color = "blue") +
  geom_area(data = subset(df, x >= x1 & x <= x2), 
            aes(x = x, y = y), 
            fill = "blue", 
            alpha = 0.2) +
  labs(title = str_glue("F Distribution (df1 = {df1}, df2 = {df2})"),
       x = "x",
       y = "Probability Density",
       caption = str_glue("P({x1} < X < {x2}) = {round(prob, 4)}")) +
  theme_minimal()

How to Calculate F Distribution in Python

Python
import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns

# Set parameters
df1 = 4  # numerator degrees of freedom
df2 = 10 # denominator degrees of freedom

# Calculate probability between two values
x1, x2 = 0.5, 2.5
prob = stats.f.cdf(x2, df1, df2) - stats.f.cdf(x1, df1, df2)
print(f"P({x1} < X < {x2}) = {prob:.4f}") # P(0.5 < X < 2.5) = 0.6274

# Calculate probability density at x1
pdf_at_x1 = stats.f.pdf(x1, df1, df2)
print(f"f({x1}) = {pdf_at_x1:.4f}") # f(0.5) = 0.6698

# Calculate cumulative probability at x1
cdf_at_x1 = stats.f.cdf(x1, df1, df2)
print(f"P(X ≤ {x1}) = {cdf_at_x1:.4f}") # P(X ≤ 0.5) = 0.2632

# Create plot
x = np.linspace(0, 5, 1000)
pdf = stats.f.pdf(x, df1, df2)

plt.figure(figsize=(10, 6))
plt.plot(x, pdf, 'blue', label='PDF')

# Add shaded area
x_shade = x[(x >= x1) & (x <= x2)]
pdf_shade = stats.f.pdf(x_shade, df1, df2)
plt.fill_between(x_shade, pdf_shade, alpha=0.2, color='blue')

# Customize plot
plt.title(f'F Distribution (df1 = {df1}, df2 = {df2})')
plt.xlabel('x')
plt.ylabel('Probability Density')
plt.grid(True, alpha=0.3)
plt.show()