Variance Calculator — Population vs Sample Variance & Standard Deviation
Calculate variance for any dataset. Covers population variance, sample variance, the n vs n-1 difference, standard deviation relationship, and a worked example.
Variance measures how spread out a set of numbers is around their mean. A small variance means the data clusters tightly; a large variance means it's spread wide. It's the foundation of standard deviation, statistical testing, and risk quantification in finance. Calculate variance for any dataset at CalcHub.
Population Variance
Use this when your data is the entire population (every member included):
$$\sigma^2 = \frac{\sum_{i=1}^{N}(x_i - \mu)^2}{N}$$
Where μ is the population mean and N is the total count.
Sample Variance
Use this when your data is a sample drawn from a larger population:
$$s^2 = \frac{\sum_{i=1}^{n}(x_i - \bar{x})^2}{n-1}$$
Where x̄ is the sample mean and n is the sample count.
Worked Example
Dataset: Test scores: 72, 85, 90, 88, 78 Step 1 — Find the mean: x̄ = (72 + 85 + 90 + 88 + 78) / 5 = 413/5 = 82.6 Step 2 — Find squared deviations:| Score (xᵢ) | xᵢ − x̄ | (xᵢ − x̄)² |
|---|---|---|
| 72 | −10.6 | 112.36 |
| 85 | 2.4 | 5.76 |
| 90 | 7.4 | 54.76 |
| 88 | 5.4 | 29.16 |
| 78 | −4.6 | 21.16 |
| Sum | 223.20 |
Why n−1 Instead of n? (Bessel's Correction)
When estimating the variance of a population from a sample, dividing by n tends to underestimate the true variance. The sample mean x̄ is calculated from the same data, which pulls the deviations inward — systematically shrinking them.
Dividing by n−1 corrects for this bias. The resulting sample variance is an unbiased estimator of the population variance: on average, it equals the true variance.
The n−1 denominator also makes sense from degrees of freedom: once you fix the mean of n numbers, only n−1 values are "free to vary" — the last one is determined.
Relationship Between Variance and Standard Deviation
$$s = \sqrt{s^2} \quad \text{and} \quad s^2 = s \times s$$
Standard deviation has the same units as the data (cm, kg, $). Variance is in squared units (cm², kg², $²). Standard deviation is more intuitive for interpretation; variance is more mathematically convenient (variances add; standard deviations don't).
Variance in Finance: Portfolio Risk
In portfolio theory, variance measures investment risk. The variance of a portfolio is:
σ²_p = w₁²σ₁² + w₂²σ₂² + 2w₁w₂ρ₁₂σ₁σ₂
Where w are weights, σ² are variances, and ρ is the correlation between assets. This is why diversification reduces risk — negative correlation reduces the covariance term.
When should I use population vs. sample variance?
Use population variance (divide by N) when you have data on every member of the group — e.g., all 30 students in one class. Use sample variance (divide by n−1) when your data is a subset and you're trying to infer about a larger group — e.g., 30 students sampled from all schools in a city. In practice, most real-world data is a sample.
Why is variance squared and not just the average of absolute deviations?
The mean absolute deviation (average of |xᵢ − x̄|) is also a valid spread measure. Variance (squared deviations) is mathematically more tractable — it's differentiable, decomposes additively for independent variables, and connects naturally to the normal distribution. However, for robust statistics (especially with outliers), mean absolute deviation can be preferable.
What is coefficient of variation?
CV = (standard deviation / mean) × 100%. It normalizes variability relative to the mean, allowing comparison of datasets with different scales. A salary dataset with mean ₹50,000 and σ ₹10,000 has CV = 20%. A height dataset with mean 170 cm and σ 5 cm has CV = 2.9% — heights are far less variable relative to their mean.