Descriptive statistics
Variance Calculator
The average squared distance from the mean — and why the divisor is n − 1 rather than n.
Have a spreadsheet? Drop a CSV here
Or . CSV, TSV or plain text. You pick which column is which after it loads — the names in your file do not have to match ours. The file is read in your browser and never uploaded.
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.
The formula
- the sample variance — an estimate of the population's
- the population variance, when the data are the whole population
- 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%.
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.
- 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
- Square each deviation and add them up.Σ(x − x̄)² = 718.67
- Sample variance: divide by n − 1 = 11.718.67 / 11 = 65.33
- Population variance: divide by n = 12.718.67 / 12 = 59.89
- The standard deviation is the square root of the sample variance.√65.33 = 8.08
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.
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.
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.