Skip to content
ENExplore Calculators

Variance Calculator

Calculate the variance of a dataset used to measure feature spread in ML pipelines.

About Variance Calculator

Variance measures how spread out a dataset is around its mean: var = Σ(x − mean)² / n for the population variance, or Σ(x − mean)² / (n−1) for the sample variance. The (n−1) divisor (Bessel's correction) makes the sample variance an unbiased estimator of the true population variance when working from a sample. In ML, variance is central to feature scaling, understanding model output stability (variance in predictions across bootstrap samples), and diagnosing overfitting via the bias-variance tradeoff.

Formulas

Sample variance

s^2 = sum((x_i - mean)^2) / (n - 1)

x_i
Individual data values
mean
Arithmetic mean of the dataset
n
Number of values

Population variance

sigma^2 = sum((x_i - mean)^2) / n

x_i
Individual data values
mean
Arithmetic mean of the dataset
n
Number of values

Worked example

With the default values below, Variance Calculator returns Sample Variance of 182.0000. Change any input above and every figure here is recalculated in your browser.

Inputs used

Dataset
4, 8, 15, 16, 23, 42

Results

Sample Variance
182.0000
Population Variance
151.6667
Mean
18.0000
Count (n)
6

Step by step

  1. 1Mean= 18.0000
  2. 2Sum of squared deviations: Σ(x − mean)²= 910.0000
  3. 3Sample variance: Σ(x−mean)² ÷ (n−1)= 182.0000
  4. 4Population variance: Σ(x−mean)² ÷ n= 151.6667

Assumptions and limits

  • The result is derived only from the single input listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

When should I use sample vs. population variance?

Use sample variance (÷ n−1) when your data is a subset drawn from a larger population — the common case in ML datasets; use population variance (÷ n) only when your data represents the entire population of interest.

Why does the sample variance divide by n−1 instead of n?

Dividing by n tends to underestimate the true population variance when using the sample mean (rather than the unknown true mean) in the calculation; dividing by n−1 corrects this bias, which is known as Bessel's correction.

How is variance related to standard deviation?

Standard deviation is simply the square root of variance — variance is in squared units of the original data, while standard deviation is in the same units, making it easier to interpret directly.

How is variance used in the bias-variance tradeoff?

In ML, 'variance' in this context refers to how much a model's predictions change across different training sets — high-variance models (like deep decision trees) overfit noise, while high-bias models (like linear regression on nonlinear data) underfit; the mathematical variance computed here is the building block for that broader concept.

Variance Calculator (AI & ML) – Calculate Sample Variance