Variance Calculator
Calculate the population or sample variance, mean, and standard deviation of any dataset, with step-by-step results.
How It's Calculated
Formula
\sigma^2 = \frac{\sum (x_i - \mu)^2}{N} \quad\text{(population)} \qquad s^2 = \frac{\sum (x_i - \bar{x})^2}{n-1} \quad\text{(sample)}Variance measures how spread out a set of numbers is around its average, expressed in squared units of the original data. It's the building block standard deviation is derived from: standard deviation is simply the square root of variance, taken specifically to bring the spread measure back into the same units as the original data (so it's directly comparable to the values themselves). Variance itself skips that last step, which is exactly why it's reported in squared units — if your dataset is measured in dollars, variance is in dollars squared; if it's measured in seconds, variance is in seconds squared. That squared-units property makes variance less intuitive to read on its own, but it's mathematically more fundamental: variance is what's actually used inside statistical formulas (ANOVA, regression, portfolio theory, hypothesis testing) because squared deviations combine additively in ways that standard deviations don't. This calculator computes the count, sum, mean, variance, and standard deviation of any dataset you enter, using either the population or sample formula. Population variance is the correct choice when your dataset IS the entire group you care about; sample variance is the correct choice when your dataset is only a subset drawn from a larger population you're trying to describe. The two formulas differ only in what they divide by: population divides by N (the full count), while sample divides by n − 1 (Bessel's correction), which corrects for the fact that a sample's own mean is, on average, slightly closer to the sample's own data points than the true population mean would be.
Worked Examples
Population variance
- Dataset: 2, 4, 4, 4, 5, 5, 7, 9 (N = 8, treated as the entire population)
- Mean (μ) = (2+4+4+4+5+5+7+9) / 8 = 40 / 8 = 5
- Squared deviations from the mean: 9, 1, 1, 1, 0, 0, 4, 16
- Sum of squared deviations = 32
- Population variance = 32 / N = 32 / 8 = 4
- (Standard deviation, for reference, would be √4 = 2 — but the variance itself, 4, is reported in squared units of the original data)
Sample variance
- Dataset: 2, 4, 4, 4, 5, 5, 7, 9 (n = 8, treated as a sample of a larger population)
- Mean (x̄) = 40 / 8 = 5 (calculated the same way as the population mean)
- Sum of squared deviations from the mean = 32 (same as above — the deviations don't change)
- Sample variance = 32 / (n − 1) = 32 / 7 ≈ 4.5714
- Notice this is larger than the population result (4) — dividing by n − 1 instead of N always produces an equal or larger estimate, which is Bessel's correction at work
Frequently Asked Questions
Why is variance reported in squared units instead of the original units?
Variance is calculated by averaging squared deviations from the mean — squaring each deviation before averaging is what makes every deviation positive (so they don't cancel out), but it also means the result's units are squared. If your dataset is in dollars, variance is in dollars squared. Standard deviation exists specifically to undo that squaring: it's the square root of variance, which brings the spread measure back into the same units as the original data and makes it directly comparable to individual values.
When should I use variance instead of standard deviation?
Use standard deviation when you want a spread measure that's directly comparable to your original data (for reporting, or for eyeballing how far a typical value falls from the mean). Use variance when you're feeding the result into further statistical calculations — ANOVA, regression, portfolio risk models, and hypothesis tests are typically built directly on variance because squared deviations combine additively (variances of independent variables add together; standard deviations don't).
Should I use population or sample variance?
Use population when your dataset contains every member of the group you're describing. Use sample when your dataset is only a subset used to estimate a larger, unmeasured population — for example, 30 survey responses standing in for all of your customers. When in doubt, sample is the more common and more conservative choice for real-world data collection.
Why do I need at least 2 values for a sample variance?
Sample variance divides by n − 1. With a single value, n − 1 = 0, which is a division by zero — there is no meaningful sample spread from one data point alone. Population variance has no such restriction: a population of one value is mathematically valid and simply has a variance of 0.
What happens if I enter a non-numeric or blank value?
The calculation is not performed and a clear message identifies which row is the problem. This calculator deliberately does not silently drop invalid rows and calculate with what's left, since doing so would quietly change your dataset without telling you. Fix or remove the flagged row to get a result.