How to Calculate Variance
Variance measures how far a set of numbers spreads out from its mean. Here is the method, step by step, with a worked example you can check in the calculator.
Open the variance calculatorThe variance formulas
For a full population of N values with mean μ: σ² = Σ(x − μ)² / N. For a sample of n values with mean x̄: s² = Σ(x − x̄)² / (n − 1). Use the population formula only when your data is every member of the group you care about; otherwise use the sample formula.
Step-by-step method
- Add up all the values and divide by how many there are to get the mean.
- Subtract the mean from each value to get its deviation.
- Square each deviation so negatives do not cancel positives.
- Add the squares together. This is the sum of squares.
- Divide by
Nfor population variance orn − 1for sample variance.
Worked example
Data set: 2, 4, 4, 4, 5, 5, 7, 9 (n = 8).
- Mean: (2 + 4 + 4 + 4 + 5 + 5 + 7 + 9) / 8 = 40 / 8 = 5.
- Deviations: −3, −1, −1, −1, 0, 0, 2, 4.
- Squared deviations: 9, 1, 1, 1, 0, 0, 4, 16.
- Sum of squares: 9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32.
- Population variance: 32 / 8 = 4 (standard deviation 2).
- Sample variance: 32 / 7 ≈ 4.5714 (standard deviation ≈ 2.1381).
Paste the same numbers into the variance calculator to see each of these steps worked out automatically.
Common mistakes
- Using the population formula on a sample, which understates the spread.
- Squaring the data instead of the deviations from the mean.
- Forgetting that variance is in squared units; take the square root for standard deviation.
Related
Need the spread in the original units? See thestandard deviation calculator.
Frequently asked questions
What is the formula for variance?
Population variance is σ² = Σ(x − μ)² / N. Sample variance is s² = Σ(x − x̄)² / (n − 1). Both add up the squared distances from the mean; the sample version divides by n − 1 instead of n.
Why do we divide by n − 1 for sample variance?
A sample's own mean sits closer to its data than the true population mean does, so dividing by n underestimates the spread. Dividing by n − 1 (Bessel's correction) removes that bias.
Can variance be negative?
No. Variance is an average of squared values, so it is zero or positive. It is zero only when every value is identical.
How is variance related to standard deviation?
Standard deviation is the square root of variance. It is expressed in the same units as the data, which makes it easier to interpret.