The calculation of a sample variance or standard deviation is typically stated as a fraction. The numerator of this fraction involves a sum of squared deviations from the mean. In statistics, the formula for this total sum of squares is

Σ (x_{i} - x̄)^{2}

Here the symbol x̄ refers to the sample mean, and the symbol Σ tells us to add up the squared differences (x_{i} - x̄) for all *i*.

While this formula works for calculations, there is an equivalent, shortcut formula that does not require us to first calculate the sample mean. This shortcut formula for the sum of squares is

Σ(x_{i}^{2})-(Σ x_{i})^{2}/*n*

Here the variable *n* refers to the number of data points in our sample.

## Standard Formula Example

To see how this shortcut formula works, we will consider an example that is calculated using both formulas. Suppose our sample is 2, 4, 6, 8. The sample mean is (2 + 4 + 6 + 8)/4 = 20/4 = 5. Now we calculate the difference of each data point with the mean 5.

- 2 – 5 = -3
- 4 – 5 = -1
- 6 – 5 = 1
- 8 – 5 = 3

We now square each of these numbers and add them together. (-3)^{2} + (-1)^{2} + 1^{2} + 3^{2} = 9 + 1 + 1 + 9 = 20.

## Shortcut Formula Example

Now we will use the same set of data: 2, 4, 6, 8, with the shortcut formula to determine the sum of squares. We first square each data point and add them together: 2^{2} + 4^{2} + 6^{2} + 8^{2} = 4 + 16 + 36 + 64 = 120.

The next step is to add together all of the data and square this sum: (2 + 4 + 6 + 8)^{2} = 400. We divide this by the number of data points to obtain 400/4 =100.

We now subtract this number from 120. This gives us that the sum of the squared deviations is 20. This was exactly the number that we have already found from the other formula.

## How Does This Work?

Many people will just accept the formula at face value and do not have any idea why this formula works. By using a little bit of algebra, we can see why this shortcut formula is equivalent to the standard, traditional way of calculating the sum of squared deviations.

Although there may be hundreds, if not thousands of values in a real-world data set, we will assume that there are only three data values: x_{1} , x_{2}, x_{3}. What we see here could be expanded to a data set that has thousands of points.

We begin by noting that( x_{1} + x_{2} + x_{3}) = 3 x̄. The expression Σ(x_{i} - x̄)^{2} = (x_{1} - x̄)^{2} + (x_{2} - x̄)^{2} + (x_{3} - x̄)^{2}.

We now use the fact from basic algebra that (a + b)^{2} = a^{2} +2ab + b^{2}. This means that (x_{1} - x̄)^{2} = x_{1}^{2} -2x_{1} x̄+ x̄^{2}. We do this for the other two terms of our summation, and we have:

x_{1}^{2} -2x_{1} x̄+ x̄^{2} + x_{2}^{2} -2x_{2} x̄+ x̄^{2} + x_{3}^{2} -2x_{3} x̄+ x̄^{2}.

We rearrange this and have:

x_{1}^{2}+ x_{2}^{2} + x_{3}^{2}+ 3x̄^{2} - 2x̄(x_{1} + x_{2} + x_{3}) .

By rewriting (x_{1} + x_{2} + x_{3}) = 3x̄ the above becomes:

x_{1}^{2}+ x_{2}^{2} + x_{3}^{2} - 3x̄^{2}.

Now since 3x̄^{2} = (x_{1}+ x_{2} + x_{3})^{2}/3, our formula becomes:

x_{1}^{2}+ x_{2}^{2} + x_{3}^{2} - (x_{1}+ x_{2} + x_{3})^{2}/3

And this is a special case of the general formula that was mentioned above:

Σ(x_{i}^{2})-(Σ x_{i})^{2}/*n*

## Is It Really a Shortcut?

It may not seem like this formula is truly a shortcut. After all, in the example above it seems that there are just as many calculations. Part of this has to do with the fact that we only looked at a sample size that was small.

As we increase the size of our sample, we see that the shortcut formula reduces the number of calculations by about half. We do not need to subtract the mean from each data point and then square the result. This cuts down considerably on the total number of operations.