How to Calculate Variance

The variance formula for samples and populations, then a worked example with a deviations table, plus the shortcut formula for calculating by hand.

How to Calculate Variance: The Actionable Formula

You have a set of numbers and you need to know how spread out they are. The standard answer is variance. But the manual calculation trips nearly everyone up: you square deviations, you divide by n or n-1, and the result is in squared units you cannot interpret directly. This is how to calculate variance by hand, step by step, so you get the correct number and understand why the formula looks the way it does. The method works identically whether you are studying for AP Statistics, running a quality-control check, or building a two-asset portfolio variance for a finance exam.

Variance is the average of the squared differences from the mean. That is the definition from both OpenStax Introductory Statistics 2e section 2.7 and the NIST e-Handbook 1.3.5.6. Every other measure of spread, standard deviation, coefficient of variation, range, starts from this single number. Learn that one sentence.

The Two Variance Formulas and Every Symbol

The variance formula exists in two versions. One for a population, one for a sample. You must know which data you have before you pick the denominator.

Population Variance (σ²)

σ² = Σ(x - μ)² / N

σ² is the population variance. Σ means 'sum of'. x is each individual data point. μ is the population mean. N is the total number of data points in the group. Use this only when you have data for every single member of the group, for example, all students in a class of 25.

Sample Variance (s²)

s² = Σ(x - x̄)² / (n - 1)

s² is the sample variance. x̄ is the sample mean. n is the sample size. The denominator uses (n - 1), which is Bessel's correction. This adjustment makes the sample variance an unbiased estimator of the population variance. Casella & Berger, Statistical Inference, provides the mathematical proof that E[s²] = σ². Most real-world data is a sample, so this formula is the one you will use far more often.

The numerator in both formulas is the sum of squared deviations (SS). That is the total of (each value minus the mean) squared. SS grows with the number of data points, so it cannot be compared across datasets. Variance solves that by dividing.

Variance Step By Step: The Four-Step Process

Every variance calculation follows the same four steps. Work through them in order and you will never get lost.

Step 1: Find the Mean

Add every data point. Divide by the count. The result is the mean, μ if it is a population, x̄ if it is a sample. Write it down. Round to at least two decimal places; rounding to fewer digits early is the most common source of error in the final variance.

Step 2: Calculate the Deviations

Subtract the mean from every data point. The result is the deviation. It can be negative or positive. The sum of all deviations from the mean is always zero, which is why you square them in the next step. If your deviations do not sum to zero (or very near it due to rounding), you made a mistake in the mean or the subtraction.

Step 3: Square Each Deviation and Sum Them

Multiply each deviation by itself. Squaring removes the negative signs and gives more weight to data points that are far from the mean. Add all the squared deviations. This total is the sum of squared deviations (SS).

Step 4: Divide by N or n - 1

For a population, divide SS by N. The result is σ². For a sample, divide SS by (n - 1). The result is s². The choice of denominator is the single most common point of confusion. If you are unsure, ask: 'Do I have every member of the group?' If no, use n - 1.

Worked Example: Population Variance

Take the final exam scores of all 5 students in a small class: 85, 92, 78, 89, 96. This is the entire population.

Step 1: Mean μ = (85 + 92 + 78 + 89 + 96) / 5 = 440 / 5 = 88.

Step 2: Deviations: 85 - 88 = -3, 92 - 88 = 4, 78 - 88 = -10, 89 - 88 = 1, 96 - 88 = 8. Sum of deviations: -3 + 4 - 10 + 1 + 8 = 0. Correct.

Step 3: Squared deviations: (-3)² = 9, 4² = 16, (-10)² = 100, 1² = 1, 8² = 64. Sum (SS) = 9 + 16 + 100 + 1 + 64 = 190.

Step 4: Population variance σ² = 190 / 5 = 38 points².

The standard deviation is √38 ≈ 6.16 points. The variance is in squared units; the standard deviation is in the original units and is easier to interpret.

Deviations Table for Population Example: Exam Scores
xDeviation (x - μ)Squared Deviation
85-39
92416
78-10100
8911
96864

Worked Example: Sample Variance

Now imagine you take a random sample of 6 daily high temperatures in January (°F): 32, 35, 28, 30, 33, 31. This is a sample, because you do not have the temperature for every January day.

Step 1: Sample mean x̄ = (32 + 35 + 28 + 30 + 33 + 31) / 6 = 189 / 6 = 31.5.

Step 2: Deviations: 32 - 31.5 = 0.5, 35 - 31.5 = 3.5, 28 - 31.5 = -3.5, 30 - 31.5 = -1.5, 33 - 31.5 = 1.5, 31 - 31.5 = -0.5. Sum of deviations: 0.5 + 3.5 - 3.5 - 1.5 + 1.5 - 0.5 = 0. Correct.

Step 3: Squared deviations: 0.5² = 0.25, 3.5² = 12.25, (-3.5)² = 12.25, (-1.5)² = 2.25, 1.5² = 2.25, (-0.5)² = 0.25. Sum (SS) = 0.25 + 12.25 + 12.25 + 2.25 + 2.25 + 0.25 = 29.5.

Step 4: Sample variance s² = 29.5 / (6 - 1) = 29.5 / 5 = 5.9 (°F)².

Sample standard deviation = √5.9 ≈ 2.43 °F. The sample variance formula uses n - 1 to correct the bias inherent in estimating the population variance from a sample. If you had divided by n = 6, you would have gotten 4.92, which is a biased underestimate of the true population spread.

Shortcut (Computational) Formula for Variance

The step-by-step method is clear but requires you to calculate the mean first and then subtract it from every data point. When you are working by hand with many numbers, the computational formula for variance is faster and reduces rounding error. The formula is the same for both population and sample; only the denominator changes.

Population: σ² = [Σx² - (Σx)² / N] / N

Sample: s² = [Σx² - (Σx)² / n] / (n - 1)

Here, Σx² is the sum of each value squared, and (Σx)² is the square of the sum of all values. The term (Σx)² / n is the correction factor that removes the need to compute each deviation individually.

Work the sample temperature example with the computational formula. Σx = 189, so (Σx)² = 35,721. Σx² = 32² + 35² + 28² + 30² + 33² + 31² = 1,024 + 1,225 + 784 + 900 + 1,089 + 961 = 5,983. Then Σx² - (Σx)² / n = 5,983 - 35,721 / 6 = 5,983 - 5,953.5 = 29.5. Divide by (n - 1) = 5 gives 5.9. The same result.

When rounding bites: if you round (Σx)² / n to 5,954, you get 5,983 - 5,954 = 29, then 29 / 5 = 5.8. That is a 1.7% error. Keep at least two extra decimal places in intermediate steps to avoid this.

Common Mistakes When Calculating Variance

These errors appear in homework, exam papers, and real-world analyses regularly. Name them and you will avoid them.

  • Using n instead of n - 1 for a sample. This is the most common mistake. It produces a biased low estimate of the population variance. Always ask: 'Is this a sample or a population?' If you are not sure, it is almost certainly a sample.
  • Forgetting to square the deviations. If you sum the raw deviations, you will always get zero. Squaring is non-negotiable.
  • Confusing variance and standard deviation. Variance is in squared units (dollars², inches²). Standard deviation is the square root and is in the original units. If you say 'the variance is 25 dollars', you are wrong. It is 25 dollars².
  • Rounding intermediate values too early. A deviation of 0.333 rounded to 0.33, then squared to 0.1089 instead of 0.110889, seems small. Over 30 data points, that error compounds. Keep three decimal places through the calculation.
  • Mistaking σx for Sx on a TI-84. The 1-Var Stats output gives both. σx is population standard deviation; Sx is sample standard deviation. A student who copies σx into a sample problem reports the wrong number. The TI-84 Plus CE Guidebook lists both outputs; you choose based on your data type.

Common Questions

What does it mean if the variance is zero?

All data points are identical. Every deviation is zero, so the sum of squared deviations is zero. Variance of a constant is always zero.

Can variance be negative?

No. Squared deviations are non-negative, and the sum of non-negative numbers divided by a positive count cannot be negative. A negative variance indicates a calculation error.

Why is variance in squared units?

Because you square the deviations. If the original data is in meters, the deviations are in meters, and squaring gives meters². That is why standard deviation, the square root, exists: it returns to the original unit.

When should I use VAR.S versus VAR.P in Excel?

Use VAR.S when your data is a sample. Use VAR.P only when you have the entire population. Using VAR.P on a sample underestimates the true variance, which can lead to overconfident conclusions.