statcompute

Descriptive statistics

Variance Calculator

The average squared distance from the mean — and why the divisor is n − 1 rather than n.

Updated August 2026Runs in your browser — nothing is uploadedVerified against R
One value per line, or separated by commas, tabs or spaces. A header row is ignored.
Leave unticked for the sample variance, which is what you want when the data are a sample from something larger.

The calculation runs in your browser, so this box needs JavaScript. The formula, the worked example and the interpretation below do not.

01

How to read this result

Variance is in squared units, which is why it is rarely reported directly. Metres become square metres, pounds become square pounds. Take the square root and you have the standard deviation, which is back in the original units and interpretable.

So why compute it at all? Because variance adds and standard deviation does not. The variance of a sum of independent quantities is the sum of their variances — that single property is what makes ANOVA, regression and almost all of inference possible.

n − 1, not n. Deviations measured from the sample mean are systematically too small, because the sample mean is by construction the point that minimises them. Dividing by n − 1 — Bessel's correction — removes that bias. Use n only when your data are the entire population.

Beware the shortcut formula. Σx² − (Σx)²/n is algebraically identical to the definition and numerically disastrous: on values around a billion it can return a negative variance. This calculator uses Welford's algorithm, which never subtracts two nearly equal large numbers.

02

The formula

s2=(xix¯)2n1σ2=(xiμ)2N
s2
the sample variance — an estimate of the population's
σ2
the population variance, when the data are the whole population
x¯,μ
the sample mean and the population mean

The only difference is the divisor. With n = 30 the two differ by about 3%; with n = 5 by 25%.

03

Worked example

The variance of twelve exam scores

The same twelve scores: 72, 85, 78, 90, 68, 95, 88, 76, 82, 91, 79, 84. Their mean is 82.33.

  1. Subtract the mean from every value.
    −10.33, 2.67, −4.33, 7.67, −14.33, 12.67, 5.67, −6.33, −0.33, 8.67, −3.33, 1.67
  2. Square each deviation and add them up.
    Σ(x − x̄)² = 718.67
  3. Sample variance: divide by n − 1 = 11.
    718.67 / 11 = 65.33
  4. Population variance: divide by n = 12.
    718.67 / 12 = 59.89
  5. The standard deviation is the square root of the sample variance.
    √65.33 = 8.08
sample variance s² 65.33population variance σ² 59.89sample SD 8.08sum of squares 718.67

The 9% gap between the two variances is Bessel's correction doing its work. It shrinks as n grows and is negligible past a few hundred observations.

Checked against R's var and sd.

The calculator above is loaded with these numbers by the Load the worked example button.

04

Assumptions, and when to use something else

Variance assumes the values are numeric and on an interval scale — differences must mean the same thing everywhere on the scale. It is extremely sensitive to outliers, because every deviation is squared: one value ten units from the mean contributes as much as a hundred values one unit away.

When outliers are a concern, the interquartile range or the median absolute deviation from the range and MAD calculator describe spread without that sensitivity.

  • You want the answer in the original unitsStandard deviationThe square root of the variance, and the number to report.
  • You are comparing spread between groupsLevene's testTests whether several groups share a variance.
  • You want spread that ignores outliersRange and MADThe interquartile range and the median absolute deviation are robust alternatives.
  • You want to compare spread across different scalesCoefficient of variationThe standard deviation as a share of the mean, which is unitless.
05

Questions people ask

Why divide by n − 1?

Because the deviations are measured from the sample mean rather than the true population mean, and the sample mean is exactly the value that makes that sum of squares as small as possible. Dividing by n therefore underestimates the population variance; n − 1 corrects it exactly on average.

When should I use the population variance?

Only when the data are the entire population you care about — every employee, every transaction in a closed period, all fifty states. If the numbers are a sample from something larger, or a snapshot of an ongoing process, use the sample version.

Can variance be negative?

Never — it is a sum of squares divided by a positive number. If software returns a negative variance, it is using the Σx² − (Σx)²/n shortcut on data with a large mean, and the answer is floating-point cancellation rather than statistics.

What is the relationship between variance and standard deviation?

The standard deviation is the square root of the variance. Variance is what the mathematics uses because it adds; standard deviation is what people report because it is in the same units as the data.