How to Calculate Variance
Learn how to calculate population and sample variance step by step. Understand the variance formula, why we divide by n−1 for samples, and how variance relates to standard deviation.
What Is Variance?
Variance measures the average squared deviation of each data point from the mean, quantifying how spread out the values in a dataset are. A small variance indicates the data points are clustered closely around the mean; a large variance indicates they are widely dispersed. Variance is the foundational concept behind standard deviation, linear regression, ANOVA, and many other statistical methods.
Population Variance Formula
When you have data for the entire population, the population variance is: σ² = Σ(xᵢ − μ)² / N, where N is the population size and μ is the population mean. Every data point's squared deviation from the mean is summed and then divided by the total number of values. The result σ² is in squared units of the original variable (e.g., square meters if x is in meters).
Sample Variance Formula
When working with a sample drawn from a larger population, the sample variance is: s² = Σ(xᵢ − x̄)² / (n − 1), where n is the sample size and x̄ is the sample mean. Dividing by n−1 instead of n is called Bessel's correction. It corrects for the bias that arises because the sample mean x̄ is used as an estimate of μ, which slightly underestimates the true spread when dividing by n.
Step-by-Step Calculation
Step 1: Calculate the mean x̄ = (Σxᵢ) / n. Step 2: Subtract the mean from each value to get the deviations: (xᵢ − x̄). Step 3: Square each deviation: (xᵢ − x̄)². Step 4: Sum all the squared deviations: Σ(xᵢ − x̄)². Step 5: Divide by n−1 for sample variance (or N for population variance). The result is s² (or σ²).
Worked Example
Dataset: [4, 8, 6, 5, 3, 2, 8, 9, 2, 5]. Mean x̄ = 52/10 = 5.2. Squared deviations: (4−5.2)² = 1.44, (8−5.2)² = 7.84, (6−5.2)² = 0.64, (5−5.2)² = 0.04, (3−5.2)² = 4.84, (2−5.2)² = 10.24, (8−5.2)² = 7.84, (9−5.2)² = 14.44, (2−5.2)² = 10.24, (5−5.2)² = 0.04. Sum = 57.6. Sample variance s² = 57.6 / 9 ≈ 6.40. Standard deviation s ≈ 2.53.
Variance vs. Standard Deviation
Standard deviation is simply the square root of variance: σ = √σ² (population) or s = √s² (sample). Standard deviation is expressed in the same units as the original data, making it easier to interpret than variance. For example, if heights are measured in centimeters, the standard deviation is in centimeters, while variance is in cm². Most practical reporting uses standard deviation, but variance is essential for mathematical derivations such as ANOVA and regression.
Properties and Uses of Variance
Variance is additive for independent random variables: Var(X + Y) = Var(X) + Var(Y) when X and Y are independent. This property underpins the derivation of standard errors and the sampling distribution of the mean. Variance is used in portfolio theory to measure financial risk, in ANOVA to decompose sources of variation in an experiment, and as the loss function in mean squared error (MSE) for regression models.
Try These Calculators
Put what you learned into practice with these free calculators.
Related Guides
How to Calculate Z-Score
Learn how to calculate a z-score step by step. Understand the z-score formula, what it means, and how to use it to compare data points across different distributions.
How to Calculate Correlation Coefficient
Understand how to calculate the Pearson correlation coefficient r from scratch. Learn the formula, step-by-step process, and how to interpret the strength and direction of a linear relationship.
How to Calculate Normal Distribution
Learn how the normal distribution works and how to calculate probabilities using it. This guide covers the probability density function, the empirical rule, standardization, and using z-tables to find area under the curve.