Written by Dackohn; last reviewed November 2026.
To calculate variance: find the mean, subtract it from each value, square the differences, add them up, and divide by n − 1 for a sample or N for a population. For 3, 7, 7, 19, the mean is 9, the squared differences sum to 144, the sample variance is 48 and the population variance is 36.
The formulas
Sample variance: s² = Σ(xi − x̄)² / (n − 1). Population variance: σ² = Σ(xi − μ)² / N.
Worked example
Data: 3, 7, 7, 19. The mean is 36 / 4 = 9.
| Value | Value − mean | Squared |
|---|---|---|
| 3 | −6 | 36 |
| 7 | −2 | 4 |
| 7 | −2 | 4 |
| 19 | 10 | 100 |
| Sum | 0 | 144 |
The differences always sum to 0, which makes a useful check on your arithmetic. Then:
- Sample variance: 144 / 3 = 48, so the sample SD is √48 = 6.93.
- Population variance: 144 / 4 = 36, so the population SD is 6.
Sample or population?
Use n − 1 when your data are a sample used to learn about a larger group, which is almost always the case. Use N only when you have every member of the group you care about, such as the marks of all students in one class when that class is all you want to describe.
Why divide by n − 1?
The deviations are measured from the sample’s own mean, which sits closer to the data than the true mean does. This makes the squared deviations slightly too small on average. Dividing by n − 1 instead of n corrects the bias. This is called Bessel’s correction, and it is linked to degrees of freedom: once the mean is fixed, only n − 1 of the deviations are free to vary.
In Excel or Google Sheets
| Quantity | Excel | Google Sheets |
|---|---|---|
| Sample variance | =VAR.S(A1:A4) | =VAR.S(A1:A4) |
| Population variance | =VAR.P(A1:A4) | =VAR.P(A1:A4) |
Variance or standard deviation?
The SD is the square root of the variance. Report the SD when describing data, since it is in the original units. Variance is useful in calculations because the variances of independent quantities add, which is the idea behind ANOVA.
Common mistakes
- Forgetting to square the differences: without squaring they sum to 0.
- Dividing by n for a sample, which underestimates the variance.
- Reporting variance in the original units. Its units are squared.
- Rounding the mean too early, which adds errors. Keep extra digits until the end.
Try it yourself
Descriptive Statistics Calculator →Get the variance, SD and more from your data. How to Calculate Standard Deviation →The next step, worked by hand.Frequently asked questions
What is the difference between sample and population variance?
Sample variance divides by n - 1 and estimates a larger group. Population variance divides by N and describes a complete group.
Can variance be negative?
No. It is an average of squared values, so the smallest possible value is 0, when all values are identical.
How do I calculate variance in Excel?
Use =VAR.S(range) for a sample or =VAR.P(range) for a whole population.
Related reading: How to calculate standard deviation · Standard deviation vs standard error · Degrees of freedom explained
Sources & further reading: NIST/SEMATECH e-Handbook of Statistical Methods · OpenStax Introductory Statistics. How we compute & validate: methodology. Written & reviewed by Dackohn; last reviewed August 2026.