## The Problem

The variance is a measure of the variability in the data. The standard deviation is also a measure of how spread out the data are. The main advantage of the variance over the standard deviation is that variances do not involve a square root, which means variances can be easily added — standard deviations cannot.

Because the variance uses the mean in its calculations, it would only make sense to use it if the mean should also have been used. Thus, data that are highly skewed should not use the variance to represent variability. To illustrate calculating the variance, assume that you collected the following 5 data values:

21, 15, 82, 79, 96

Calculate the variance of this sample, s².

## Your Answer

You got the correct answer of **1419.3**. Congratulations!

Unfortunately, your answer was not correct. Either try again or click on “Show Solution” below to see how to obtain the correct answer.

## Assistance

Hide Solution

$$
\begin{align}
s^2 &= \frac{1}{n-1} \sum_{i=1}^{n} (x_i-\bar{x})^2 \\
&= \frac{1}{5-1} \sum_{i=1}^{5} (x_i-59)^2 \\
&= \frac{1}{4} \left( (21-58.6)^2 + (15-58.6)^2 + (82-58.6)^2 + (79-58.6)^2 + (96-59)^2 \right) \\
&= \frac{1}{4} \left( (-37.6)^2 + (-43.6)^2 + (23.4)^2 + (20.4)^2 + (37.4)^2 \right) \\
&= \frac{1}{4} \left( (1413.76) + (1900.96) + (547.56) + (416.16) + (1398.76) \right) \\
\end{align}
$$

Thus, the variance of these 5 values is 1419.3.

Hide the R Code

Copy and paste the following code into your R script window, then run it from there.

sample = c(21, 15, 82, 79, 96)

var(sample)

In the R output, the sample variance is the number output by the script.

Hide the Excel Code

Copy and paste the following code into your Excel spreadsheet window, making sure your cursor is in `A1`

when you paste.

sample

21

15

82

79

96

=VAR.S(A2:A6)

Note that the function in Excel is `VAR.S`

and *not* `VAR.P`

, which returns the *population* variance.