Calculating Variance and Standard Deviation in 4 Easy Steps

This page is a step-by-step guide to calculating variance and standard deviation.

You can easily calculate variance and standard deviation, as well as skewness, kurtosis, percentiles, and other measures, using the Descriptive Statistics Excel Calculator.

Definition of Variance

Variance is a measure of dispersion in a data set. It measures how big the differences are between individual values.

Mathematically it is the average squared difference between each occurrence (each value) and the mean of the whole data set.

Variance is the average squared deviation from the mean.

Calculation of Variance

It is easy to decipher the step-by-step calculation of variance from the definition above. Variance is the

  • average
  • squared
  • deviation from the
  • mean.

These are the four steps needed for calculating variance and you have to start from the end of the definition:

  • Step 1: mean
  • Step 2: deviation
  • Step 3: squared
  • Step 4: average

Step 1: Calculating the Mean

Let’s start with the mean. In general, mean (average) is the central value of a data set.

The best known and typical way of calculating mean is the arithmetic average:

Sum up all the numbers and then divide the sum by the count of numbers used.

For example, arithmetic average of the numbers 10, 20, 30, 40, 50 is 10+20+30+40+50 (which is 150) divided by the count of numbers (which is 5). Arithmetic average of 10, 20, 30, 40, 50 is 30.

Besides arithmetic average there are other methods how to calculate central value, such as geometric or harmonic mean. For some data sets (for example, investment returns) they may be more suitable. But we will use arithmetic average for now, to keep it simple and because that is the usual method used in variance calculation.

That’s all in step 1: Calculate the average of the numbers.

Step 2: Calculating Deviations from the Mean

In the next step we need to calculate the deviations from the mean. For each number in the set, we subtract the mean from that number. For our set of numbers 10, 20, 30, 40, 50 the deviations from the mean (which is 30) are:

  • 10 less 30 = -20
  • 20 less 30 = -10
  • 30 less 30 = 0
  • 40 less 30 = +10
  • 50 less 30 = +20

That’s all in step 2: Subtract the mean from each number.

Step 3: Squaring the Deviations

In step 3 we need to square each deviation. To square a number means to multiply that number by itself. For the numbers in our set, we get:

  • For 10 the deviation is -20 and squared deviation is -20 x -20 = 400
  • For 20 the deviation is -10 and squared deviation is -10 x -10 = 100
  • For 30 the deviation is 0 and squared deviation is 0 x 0 = 0
  • For 40 the deviation is 10 and squared deviation is 10 x 10 = 100
  • For 50 the deviation is 20 and squared deviation is 20 x 20 = 400

That was step 3: Square all the deviations.

The Importance of Squaring the Deviations

Why are we doing this? Squaring numbers has two effects.

Firstly, any negative number squared is a positive number. This way we get rid of the negative signs we had with deviations from the mean for numbers which were smaller than the mean.

Secondly, squaring gives much bigger weight to big numbers (or big negative numbers) than to numbers close to zero.

Squaring the deviations avoids some troubles we would otherwise have in the next and final step.

Step 4: Calculating Variance as Average of Squared Deviations

Now we have the squared deviations from the mean – almost the whole definition of variance. There is only one part left: the word average.

As simple as it sounds, in step 4 we will calculate arithmetic average of the squared deviations which we have just calculated in step 3.

It is the same thing as we did in step 1 – the only difference is that in step 1 we were calculating the average of the original numbers (10, 20, 30, 40, 50), but now in step 4 we are calculating the average of the squared deviations.

In our example, the squared deviations are 400, 100, 0, 100, and 400. We sum them up and get 1,000. Then we divide 1,000 by 5 and get 200. That’s it.

The variance of the set of numbers 10, 20, 30, 40, 50 is 200.

Variance is the average (step 4) squared (step 3) deviation (step 2) from the mean (step 1).

Back to the Importance of Squaring the Deviations

Let’s now briefly revisit the importance of squaring the deviations in step 3.

In fact, if we calculated the average of (not squared) deviations from the mean (variance without step 3), we would always, for any data set, get a variance of zero.

By definition (and due to the way arithmetic mean is calculated as sum of values divided by count of values), the sum (and therefore also the average) of all deviations from arithmetic mean for any set of data must be zero, because the positive and negative deviations cancel each other. By squaring them, you make all the deviations positive and they can add up.

Calculating Standard Deviation from Variance

In finance and in most other disciplines, standard deviation is used more frequently than variance. Both are measures of dispersion or volatility in a data set and they are closely related.

Standard deviation is the square root of variance.

And vice versa, variance is standard deviation squared.

To calculate standard deviation from variance, take the square root.

In our example, variance is 200, therefore standard deviation is square root of 200, which is 14.14.

To calculate standard deviation of a data set, first calculate the variance and then the square root of that.

Population vs. Sample Variance and Standard Deviation

In this tutorial we were calculating population variance and standard deviation. For sample variance and standard deviation, the only difference is in step 4, where we divide by the number of items less one.

In our example, we would divide 1,000 by 4 (5 less 1) and get the sample variance of 250. Sample standard deviation would be 15.81 (square root of 250).

For more explanation of the difference between population and sample see:

Population vs. Sample Variance and Standard Deviation.

Calculating Variance and Standard Deviation in Practice

In our example, we were calculating variance and standard deviation of a set of 5 numbers.

In reality, they are usually calculated for much bigger data sets.

For example, if you want to use standard deviation to calculate historical volatility of a stock, using only 5 occurrences will not get you far, as the sample would be too small to reveal any significant and useful information about the stock.

You will most likely work with at least tens of numbers (for example, take every day’s closing price and day-to-day performance of that stock in a period of a few months). To avoid spending several hours on calculating and squaring the individual deviations from the mean, you can easily calculate variance or standard deviation in Excel (using VAR.S, VAR.P, STDEV.S, STDEV.P or related functions).

Calculators

You can easily calculate variance and standard deviation, as well as skewness, kurtosis, percentiles, and other measures, using the Descriptive Statistics Excel Calculator.

For historical volatility of stocks and other assets, you can use the Historical Volatility Calculator.

Have a question or feedback? Send a message. It takes less than a minute.