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 set of data. It measures how big the differences are between individual numbers in a set of numbers.

Mathematically it is the **average squared difference** between each occurrence (each number) and the mean of the whole data set. **Variance** is the **average squared deviation from the mean**.

[adsense1]

## 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. **Mean** in general is the **central value** of a data set. The best known and most usual way of calculating mean is the **arithmetic average**: you sum all the numbers up and then divide the sum by the count of numbers used. For example arithmetic average of the numbers 10, 20, 30, 40, and 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, and 50 is 30.

Besides arithmetic average there are other methods how to calculate central value and for some types of data they are more suitable (for example geometric mean or harmonic mean). But we’ll use the best known arithmetic average now to keep it simple.

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

[adsense2]

## 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 simply subtract the mean from that number. For our set of numbers 10, 20, 30, 40, and 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, as you’ll see.

[adsense3]

## Step 4: Calculating variance as average of squared deviations

Now when we have the squared deviations from the mean (you see it’s almost the whole definition of variance), we have only one thing left: the word *average*.

As simple as it sounds, step 4 is only **calculating arithmetic average of the squared deviations** we have just calculated in step 3. It is exactly 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, and 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, and 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 come back to the importance of **squaring the deviations** in step 3. If you would calculate the average of (not squared) deviations from the mean (you would be calculating variance without step 3), you would always get a **variance of zero**. Why? By definition, the sum (and therefore also the average) of all deviations from arithmetic average 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 very closely related. **Standard deviation is the square root of variance**. Vice versa, variance is standard deviation squared.

To calculate standard deviation from variance, only take the **square root**. In our example, the **variance** was 200, therefore **standard deviation** is 14.14.

For **calculating standard deviation** of a data set, first calculate the **variance** and then find the square root.

## Population vs. sample variance and standard deviation

In this article 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 information regarding 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 sets of data**. For example if you want to **use variance** and **standard deviation** to **calculate historical volatility of a stock**, using only 5 occurrences will not get you anywhere, as the sample would be too small to reveal any significant and useful information to you.

You will most likely work with at least tens of numbers (for example you 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 and STDEV or related functions).

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