- Home
- >
- The Sample Variance – Explanation & Examples

JUMP TO TOPIC

# The Sample Variance – Explanation & Examples

*The definition of the sample variance is:*

*“The sample variance is the average of the squared differences from the mean found in a sample.”*

*In this topic, we will discuss the sample variance from the following aspects:*

- What is the sample variance?
- How to find the sample variance?
- Sample variance formula.
- The role of the sample variance.
- Practice questions.
- Answer key.

## What is the sample variance?

**The sample variance** is the average of the squared differences from the mean found in a sample.

The sample variance measures the spread of a numerical characteristic of your sample.

**A large variance** indicates that your sample numbers are far from the mean and far from each other.

**A small variance**, on the other hand, indicates the opposite.

**A zero variance** indicates that all values within your sample are identical.

The variance can be zero or a positive number. Still, it cannot be negative because it is mathematically impossible to have a negative value resulting from a square.

For example, if you have two sets of 3 numbers (1,2,3) and (1,2,10). You see that the second set is more spread (more varied) than the first set.

You can see that from the following dot plot.

We see that the blue dots (second group) are more spread out than the red dots (first group).

If we calculate the first group variance, it is 1, while the variance for the second group is 24.3. Therefore, the second group is more spread (more varied) than the first group.

## How to find the sample variance?

We will go through several examples, from simple to more complex ones.

### – Example 1

What is the variance of the numbers, 1,2,3?

1. Add up all of the numbers:

1+2+3 = 6.

2. Count the numbers of items in your sample. In this sample, there are 3 items.

3. Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 6/3 = 2.

4. In a table, subtract the mean from each value of your sample.

value | value-mean |

1 | -1 |

2 | 0 |

3 | 1 |

You have a table of 2 columns, one for the data values and the other column for subtracting the mean (2) from each value.

4. Add another column for the squared differences you found in Step 4.

value | value-mean | squared difference |

1 | -1 | 1 |

2 | 0 | 0 |

3 | 1 | 1 |

6. Add up all of the squared differences you found in Step 5.

1+0+1 = 2.

7. Divide the number you get in step 6 by sample size-1 to get the variance. We have 3 numbers, so the sample size is 3.

The variance = 2/(3-1) = 1.

### – Example 2

What is the variance of the numbers, 1,2,10?

1. Add up all of the numbers:

1+2+10 = 13.

2. Count the numbers of items in your sample. In this sample, there are 3 items.

3. Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 13/3 = 4.33.

4. In a table, subtract the mean from each value of your sample.

value | value-mean |

1 | -3.33 |

2 | -2.33 |

10 | 5.67 |

You have a table of 2 columns, one for the data values and the other column for subtracting the mean (4.33) from each value.

5. Add another column for the squared differences you found in Step 4.

value | value-mean | squared difference |

1 | -3.33 | 11.09 |

2 | -2.33 | 5.43 |

10 | 5.67 | 32.15 |

6. Add up all of the squared differences you found in Step 5.

11.09 + 5.43 + 32.15 = 48.67.

7. Divide the number you get in step 6 by sample size-1 to get the variance. We have 3 numbers, so the sample size is 3.

The variance = 48.67/(3-1) = 24.335.

### – Example 3

The following is the age (in years) of 25 individuals sampled from a certain population. What is the variance of this sample?

individual | age |

1 | 26 |

2 | 48 |

3 | 67 |

4 | 39 |

5 | 25 |

6 | 25 |

7 | 36 |

8 | 44 |

9 | 44 |

10 | 47 |

11 | 53 |

12 | 52 |

13 | 52 |

14 | 51 |

15 | 52 |

16 | 40 |

17 | 77 |

18 | 44 |

19 | 40 |

20 | 45 |

21 | 48 |

22 | 49 |

23 | 19 |

24 | 54 |

25 | 82 |

1. Add up all of the numbers:

26+ 48+ 67+ 39+ 25+ 25+ 36+ 44+ 44+ 47+ 53+ 52+ 52+ 51+ 52+ 40+ 77+ 44+ 40+ 45+ 48+ 49+ 19+ 54+ 82 = 1159.

2. Count the numbers of items in your sample. In this sample, there are 25 items or 25 individuals.

3. Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 1159/25 = 46.36 years.

4. In a table, subtract the mean from each value of your sample.

individual | age | age-mean |

1 | 26 | -20.36 |

2 | 48 | 1.64 |

3 | 67 | 20.64 |

4 | 39 | -7.36 |

5 | 25 | -21.36 |

6 | 25 | -21.36 |

7 | 36 | -10.36 |

8 | 44 | -2.36 |

9 | 44 | -2.36 |

10 | 47 | 0.64 |

11 | 53 | 6.64 |

12 | 52 | 5.64 |

13 | 52 | 5.64 |

14 | 51 | 4.64 |

15 | 52 | 5.64 |

16 | 40 | -6.36 |

17 | 77 | 30.64 |

18 | 44 | -2.36 |

19 | 40 | -6.36 |

20 | 45 | -1.36 |

21 | 48 | 1.64 |

22 | 49 | 2.64 |

23 | 19 | -27.36 |

24 | 54 | 7.64 |

25 | 82 | 35.64 |

There is one column for the ages and another column for subtracting the mean (46.36) from each value.

5. Add another column for the squared differences you found in Step 4.

individual | age | age-mean | squared difference |

1 | 26 | -20.36 | 414.53 |

2 | 48 | 1.64 | 2.69 |

3 | 67 | 20.64 | 426.01 |

4 | 39 | -7.36 | 54.17 |

5 | 25 | -21.36 | 456.25 |

6 | 25 | -21.36 | 456.25 |

7 | 36 | -10.36 | 107.33 |

8 | 44 | -2.36 | 5.57 |

9 | 44 | -2.36 | 5.57 |

10 | 47 | 0.64 | 0.41 |

11 | 53 | 6.64 | 44.09 |

12 | 52 | 5.64 | 31.81 |

13 | 52 | 5.64 | 31.81 |

14 | 51 | 4.64 | 21.53 |

15 | 52 | 5.64 | 31.81 |

16 | 40 | -6.36 | 40.45 |

17 | 77 | 30.64 | 938.81 |

18 | 44 | -2.36 | 5.57 |

19 | 40 | -6.36 | 40.45 |

20 | 45 | -1.36 | 1.85 |

21 | 48 | 1.64 | 2.69 |

22 | 49 | 2.64 | 6.97 |

23 | 19 | -27.36 | 748.57 |

24 | 54 | 7.64 | 58.37 |

25 | 82 | 35.64 | 1270.21 |

6. Add up all of the squared differences you found in Step 5.

414.53+ 2.69+ 426.01+ 54.17+ 456.25+ 456.25+ 107.33+ 5.57+ 5.57+ 0.41+ 44.09+ 31.81+ 31.81+ 21.53+ 31.81+ 40.45+ 938.81+ 5.57+ 40.45+ 1.85+ 2.69+ 6.97+ 748.57+ 58.37+ 1270.21 = 5203.77.

7. Divide the number you get in step 6 by sample size-1 to get the variance. We have 25 numbers so the sample size is 25.

The variance = 5203.77/(25-1) = 216.82 years^2.

**Note that the sample variance** has the squared unit of the original data (years^2) due to the presence of squared difference in its calculation.

### – Example 4

The following is the score (in points) of 10 students in an easy exam. What is the variance of this sample?

student | score |

1 | 100 |

2 | 100 |

3 | 100 |

4 | 100 |

5 | 100 |

6 | 100 |

7 | 100 |

8 | 100 |

9 | 100 |

10 | 100 |

All students have 100 points on this exam.

1. Add up all of the numbers:

Sum = 1000.

2. Count the numbers of items in your sample. In this sample, there are 10 items or students.

3. Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 1000/10 = 100.

4. In a table, subtract the mean from each value of your sample.

student | score | score-mean |

1 | 100 | 0 |

2 | 100 | 0 |

3 | 100 | 0 |

4 | 100 | 0 |

5 | 100 | 0 |

6 | 100 | 0 |

7 | 100 | 0 |

8 | 100 | 0 |

9 | 100 | 0 |

10 | 100 | 0 |

5. Add another column for the squared differences you found in Step 4.

student | score | score-mean | squared difference |

1 | 100 | 0 | 0 |

2 | 100 | 0 | 0 |

3 | 100 | 0 | 0 |

4 | 100 | 0 | 0 |

5 | 100 | 0 | 0 |

6 | 100 | 0 | 0 |

7 | 100 | 0 | 0 |

8 | 100 | 0 | 0 |

9 | 100 | 0 | 0 |

10 | 100 | 0 | 0 |

6. Add up all of the squared differences you found in Step 5.

Sum = 0.

7. Divide the number you get in step 6 by sample size-1 to get the variance. We have 10 numbers, so the sample size is 10.

The variance = 0/(10-1) = 0 points^2.

The variance can be zero if all our sample values are identical.

### – Example 5

The following table shows the daily closing prices (in US dollars or USD) of Facebook (FB) and Google (GOOG) stocks in some days of 2013. Which stock has a more variable closing stock price?

**Note that** **we compare** the two stocks from the same sector (communication services) and for the same period.

date | FB | GOOG |

2013-01-02 | 28.00 | 723.2512 |

2013-01-03 | 27.77 | 723.6713 |

2013-01-04 | 28.76 | 737.9713 |

2013-01-07 | 29.42 | 734.7513 |

2013-01-08 | 29.06 | 733.3012 |

2013-01-09 | 30.59 | 738.1212 |

2013-01-10 | 31.30 | 741.4813 |

2013-01-11 | 31.72 | 739.9913 |

2013-01-14 | 30.95 | 723.2512 |

2013-01-15 | 30.10 | 724.9313 |

2013-01-16 | 29.85 | 715.1912 |

2013-01-17 | 30.14 | 711.3212 |

2013-01-18 | 29.66 | 704.5112 |

2013-01-22 | 30.73 | 702.8712 |

2013-01-23 | 30.82 | 741.5013 |

2013-01-24 | 31.08 | 754.2113 |

2013-01-25 | 31.54 | 753.6713 |

2013-01-28 | 32.47 | 750.7313 |

2013-01-29 | 30.79 | 753.6813 |

2013-01-30 | 31.24 | 753.8313 |

2013-01-31 | 30.98 | 755.6913 |

2013-02-01 | 29.73 | 775.6013 |

2013-02-04 | 28.11 | 759.0213 |

2013-02-05 | 28.64 | 765.7413 |

2013-02-06 | 29.05 | 770.1713 |

2013-02-07 | 28.65 | 773.9513 |

2013-02-08 | 28.55 | 785.3714 |

2013-02-11 | 28.26 | 782.4213 |

2013-02-12 | 27.37 | 780.7013 |

2013-02-13 | 27.91 | 782.8613 |

2013-02-14 | 28.50 | 787.8214 |

2013-02-15 | 28.32 | 792.8913 |

2013-02-19 | 28.93 | 806.8514 |

2013-02-20 | 28.46 | 792.4613 |

2013-02-21 | 27.28 | 795.5313 |

2013-02-22 | 27.13 | 799.7114 |

2013-02-25 | 27.27 | 790.7714 |

2013-02-26 | 27.39 | 790.1313 |

2013-02-27 | 26.87 | 799.7813 |

2013-02-28 | 27.25 | 801.2014 |

2013-03-01 | 27.78 | 806.1914 |

2013-03-04 | 27.72 | 821.5014 |

2013-03-05 | 27.52 | 838.6014 |

2013-03-06 | 27.45 | 831.3814 |

2013-03-07 | 28.58 | 832.6014 |

2013-03-08 | 27.96 | 831.5214 |

2013-03-11 | 28.14 | 834.8214 |

2013-03-12 | 27.83 | 827.6114 |

2013-03-13 | 27.08 | 825.3114 |

2013-03-14 | 27.04 | 821.5414 |

We will calculate the variance for each stock then compare between them.

*The variance of Facebook stock closing price is calculated as follows:*

1. Add up all of the numbers:

28.00+ 27.77+ 28.76+ 29.42+ 29.06+ 30.59+ 31.30+ 31.72+ 30.95+ 30.10+ 29.85+ 30.14+ 29.66+ 30.73+ 30.82+ 31.08+ 31.54+ 32.47+ 30.79+ 31.24+ 30.98+ 29.73+ 28.11+ 28.64+ 29.05+ 28.65+ 28.55+ 28.26+ 27.37+ 27.91+ 28.50+ 28.32+ 28.93+ 28.46+ 27.28+ 27.13+ 27.27+ 27.39+ 26.87+ 27.25+ 27.78+ 27.72+ 27.52+ 27.45+ 28.58+ 27.96+ 28.14+ 27.83+ 27.08+ 27.04 = 1447.74.

2. Count the numbers of items in your sample. In this sample, there are 50 items.

3. Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 1447.74/50 = 28.9548 USD.

4. In a table, subtract the mean from each value of your sample.

FB | stock-mean |

28.00 | -0.9548 |

27.77 | -1.1848 |

28.76 | -0.1948 |

29.42 | 0.4652 |

29.06 | 0.1052 |

30.59 | 1.6352 |

31.30 | 2.3452 |

31.72 | 2.7652 |

30.95 | 1.9952 |

30.10 | 1.1452 |

29.85 | 0.8952 |

30.14 | 1.1852 |

29.66 | 0.7052 |

30.73 | 1.7752 |

30.82 | 1.8652 |

31.08 | 2.1252 |

31.54 | 2.5852 |

32.47 | 3.5152 |

30.79 | 1.8352 |

31.24 | 2.2852 |

30.98 | 2.0252 |

29.73 | 0.7752 |

28.11 | -0.8448 |

28.64 | -0.3148 |

29.05 | 0.0952 |

28.65 | -0.3048 |

28.55 | -0.4048 |

28.26 | -0.6948 |

27.37 | -1.5848 |

27.91 | -1.0448 |

28.50 | -0.4548 |

28.32 | -0.6348 |

28.93 | -0.0248 |

28.46 | -0.4948 |

27.28 | -1.6748 |

27.13 | -1.8248 |

27.27 | -1.6848 |

27.39 | -1.5648 |

26.87 | -2.0848 |

27.25 | -1.7048 |

27.78 | -1.1748 |

27.72 | -1.2348 |

27.52 | -1.4348 |

27.45 | -1.5048 |

28.58 | -0.3748 |

27.96 | -0.9948 |

28.14 | -0.8148 |

27.83 | -1.1248 |

27.08 | -1.8748 |

27.04 | -1.9148 |

There is one column for the stock prices and another column for subtracting the mean (28.9548) from each value.

5. Add another column for the squared differences you found in Step 4.

FB | stock-mean | squared difference |

28.00 | -0.9548 | 0.91 |

27.77 | -1.1848 | 1.40 |

28.76 | -0.1948 | 0.04 |

29.42 | 0.4652 | 0.22 |

29.06 | 0.1052 | 0.01 |

30.59 | 1.6352 | 2.67 |

31.30 | 2.3452 | 5.50 |

31.72 | 2.7652 | 7.65 |

30.95 | 1.9952 | 3.98 |

30.10 | 1.1452 | 1.31 |

29.85 | 0.8952 | 0.80 |

30.14 | 1.1852 | 1.40 |

29.66 | 0.7052 | 0.50 |

30.73 | 1.7752 | 3.15 |

30.82 | 1.8652 | 3.48 |

31.08 | 2.1252 | 4.52 |

31.54 | 2.5852 | 6.68 |

32.47 | 3.5152 | 12.36 |

30.79 | 1.8352 | 3.37 |

31.24 | 2.2852 | 5.22 |

30.98 | 2.0252 | 4.10 |

29.73 | 0.7752 | 0.60 |

28.11 | -0.8448 | 0.71 |

28.64 | -0.3148 | 0.10 |

29.05 | 0.0952 | 0.01 |

28.65 | -0.3048 | 0.09 |

28.55 | -0.4048 | 0.16 |

28.26 | -0.6948 | 0.48 |

27.37 | -1.5848 | 2.51 |

27.91 | -1.0448 | 1.09 |

28.50 | -0.4548 | 0.21 |

28.32 | -0.6348 | 0.40 |

28.93 | -0.0248 | 0.00 |

28.46 | -0.4948 | 0.24 |

27.28 | -1.6748 | 2.80 |

27.13 | -1.8248 | 3.33 |

27.27 | -1.6848 | 2.84 |

27.39 | -1.5648 | 2.45 |

26.87 | -2.0848 | 4.35 |

27.25 | -1.7048 | 2.91 |

27.78 | -1.1748 | 1.38 |

27.72 | -1.2348 | 1.52 |

27.52 | -1.4348 | 2.06 |

27.45 | -1.5048 | 2.26 |

28.58 | -0.3748 | 0.14 |

27.96 | -0.9948 | 0.99 |

28.14 | -0.8148 | 0.66 |

27.83 | -1.1248 | 1.27 |

27.08 | -1.8748 | 3.51 |

27.04 | -1.9148 | 3.67 |

6. Add up all of the squared differences you found in Step 5.

0.91+ 1.40+ 0.04+ 0.22+ 0.01+ 2.67+ 5.50+ 7.65+ 3.98+ 1.31+ 0.80+ 1.40+ 0.50+ 3.15+ 3.48+ 4.52+ 6.68+ 12.36+ 3.37+ 5.22+ 4.10+ 0.60+ 0.71+ 0.10+ 0.01+ 0.09+ 0.16+ 0.48+ 2.51+ 1.09+ 0.21+ 0.40+ 0.00+ 0.24+ 2.80+ 3.33+ 2.84+ 2.45+ 4.35+ 2.91+ 1.38+ 1.52+ 2.06+ 2.26+ 0.14+ 0.99+ 0.66+ 1.27+ 3.51+ 3.67 = 112.01.

7. Divide the number you get in step 6 by sample size-1 to get the variance. We have 50 numbers so the sample size is 50.

8. The variance of Facebook stock closing price = 112.01/(50-1) = 2.29 USD^2.

*The variance of Google stock closing price is calculated as follows:*

1. Add up all of the numbers:

723.2512+ 723.6713+ 737.9713+ 734.7513+ 733.3012+ 738.1212+ 741.4813+ 739.9913+ 723.2512+ 724.9313+ 715.1912+ 711.3212+ 704.5112+ 702.8712+ 741.5013+ 754.2113+ 753.6713+ 750.7313+ 753.6813+ 753.8313+ 755.6913+ 775.6013+ 759.0213+ 765.7413+ 770.1713+ 773.9513+ 785.3714+ 782.4213+ 780.7013+ 782.8613+ 787.8214+ 792.8913+ 806.8514+ 792.4613+ 795.5313+ 799.7114+ 790.7714+ 790.1313+ 799.7813+ 801.2014+ 806.1914+ 821.5014+ 838.6014+ 831.3814+ 832.6014+ 831.5214+ 834.8214+ 827.6114+ 825.3114+ 821.5414 = 38622.02.

2. Count the numbers of items in your sample. In this sample, there are 50 items.

3. Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 38622.02/50 = 772.4404 USD.

4. In a table, subtract the mean from each value of your sample.

GOOG | stock-mean |

723.2512 | -49.1892 |

723.6713 | -48.7691 |

737.9713 | -34.4691 |

734.7513 | -37.6891 |

733.3012 | -39.1392 |

738.1212 | -34.3192 |

741.4813 | -30.9591 |

739.9913 | -32.4491 |

723.2512 | -49.1892 |

724.9313 | -47.5091 |

715.1912 | -57.2492 |

711.3212 | -61.1192 |

704.5112 | -67.9292 |

702.8712 | -69.5692 |

741.5013 | -30.9391 |

754.2113 | -18.2291 |

753.6713 | -18.7691 |

750.7313 | -21.7091 |

753.6813 | -18.7591 |

753.8313 | -18.6091 |

755.6913 | -16.7491 |

775.6013 | 3.1609 |

759.0213 | -13.4191 |

765.7413 | -6.6991 |

770.1713 | -2.2691 |

773.9513 | 1.5109 |

785.3714 | 12.9310 |

782.4213 | 9.9809 |

780.7013 | 8.2609 |

782.8613 | 10.4209 |

787.8214 | 15.3810 |

792.8913 | 20.4509 |

806.8514 | 34.4110 |

792.4613 | 20.0209 |

795.5313 | 23.0909 |

799.7114 | 27.2710 |

790.7714 | 18.3310 |

790.1313 | 17.6909 |

799.7813 | 27.3409 |

801.2014 | 28.7610 |

806.1914 | 33.7510 |

821.5014 | 49.0610 |

838.6014 | 66.1610 |

831.3814 | 58.9410 |

832.6014 | 60.1610 |

831.5214 | 59.0810 |

834.8214 | 62.3810 |

827.6114 | 55.1710 |

825.3114 | 52.8710 |

821.5414 | 49.1010 |

There is one column for the stock prices and another column for subtracting the mean (772.4404) from each value.

5. Add another column for the squared differences you found in Step 4.

GOOG | stock-mean | squared difference |

723.2512 | -49.1892 | 2419.58 |

723.6713 | -48.7691 | 2378.43 |

737.9713 | -34.4691 | 1188.12 |

734.7513 | -37.6891 | 1420.47 |

733.3012 | -39.1392 | 1531.88 |

738.1212 | -34.3192 | 1177.81 |

741.4813 | -30.9591 | 958.47 |

739.9913 | -32.4491 | 1052.94 |

723.2512 | -49.1892 | 2419.58 |

724.9313 | -47.5091 | 2257.11 |

715.1912 | -57.2492 | 3277.47 |

711.3212 | -61.1192 | 3735.56 |

704.5112 | -67.9292 | 4614.38 |

702.8712 | -69.5692 | 4839.87 |

741.5013 | -30.9391 | 957.23 |

754.2113 | -18.2291 | 332.30 |

753.6713 | -18.7691 | 352.28 |

750.7313 | -21.7091 | 471.29 |

753.6813 | -18.7591 | 351.90 |

753.8313 | -18.6091 | 346.30 |

755.6913 | -16.7491 | 280.53 |

775.6013 | 3.1609 | 9.99 |

759.0213 | -13.4191 | 180.07 |

765.7413 | -6.6991 | 44.88 |

770.1713 | -2.2691 | 5.15 |

773.9513 | 1.5109 | 2.28 |

785.3714 | 12.9310 | 167.21 |

782.4213 | 9.9809 | 99.62 |

780.7013 | 8.2609 | 68.24 |

782.8613 | 10.4209 | 108.60 |

787.8214 | 15.3810 | 236.58 |

792.8913 | 20.4509 | 418.24 |

806.8514 | 34.4110 | 1184.12 |

792.4613 | 20.0209 | 400.84 |

795.5313 | 23.0909 | 533.19 |

799.7114 | 27.2710 | 743.71 |

790.7714 | 18.3310 | 336.03 |

790.1313 | 17.6909 | 312.97 |

799.7813 | 27.3409 | 747.52 |

801.2014 | 28.7610 | 827.20 |

806.1914 | 33.7510 | 1139.13 |

821.5014 | 49.0610 | 2406.98 |

838.6014 | 66.1610 | 4377.28 |

831.3814 | 58.9410 | 3474.04 |

832.6014 | 60.1610 | 3619.35 |

831.5214 | 59.0810 | 3490.56 |

834.8214 | 62.3810 | 3891.39 |

827.6114 | 55.1710 | 3043.84 |

825.3114 | 52.8710 | 2795.34 |

821.5414 | 49.1010 | 2410.91 |

6. Add up all of the squared differences you found in Step 5.

2419.58+ 2378.43+ 1188.12+ 1420.47+ 1531.88+ 1177.81+ 958.47+ 1052.94+ 2419.58+ 2257.11+ 3277.47+ 3735.56+ 4614.38+ 4839.87+ 957.23+ 332.30+ 352.28+ 471.29+ 351.90+ 346.30+ 280.53+ 9.99+ 180.07+ 44.88+ 5.15+ 2.28+ 167.21+ 99.62+ 68.24+ 108.60+ 236.58+ 418.24+ 1184.12+ 400.84+ 533.19+ 743.71+ 336.03+ 312.97+ 747.52+ 827.20+ 1139.13+ 2406.98+ 4377.28+ 3474.04+ 3619.35+ 3490.56+ 3891.39+ 3043.84+ 2795.34+ 2410.91 = 73438.76.

7. Divide the number you get in step 6 by sample size-1 to get the variance. We have 50 numbers, so the sample size is 50.

The Google stock closing price variance = 73438.76/(50-1) = 1498.75 USD^2, while the variance of the Facebook stock closing price is 2.29 USD^2.

The Google stock closing price is more variable. We can see that if we plot the data as a dot plot.

In the first plot, when the x-axis is common, we see that the Facebook prices occupy a small space compared to Google prices.

In the second plot, when the x-axis values are set according to each stock’s values, we see that Facebook prices range from 27 to 32, while Google prices range from 700 to about 850.

## Sample variance formula

The **sample variance formula** is:

s^2=(∑_(i=1)^n▒( x_i-¯x )^2)/(n-1)

Where s^2 is the sample variance.

¯x is the sample mean.

n is the sample size.

*The term:*

∑_(i=1)^n▒( x_i-¯x )^2

means sum the squared difference between every element of our sample (from x_1 to x_n) and the sample mean ¯x.

Our sample element is denoted as x with a subscript to indicate its position in our sample.

In the example of stock prices for Facebook, we have 50 prices. The first price (28) is denoted as x_1, the second price (27.77) is denoted as x_2, the third price (28.76) is denoted as x_3.

The last price (27.04) is denoted as x_50 or x_n because n = 50 in this case.

We used this formula in the above examples, where we summed the squared difference between every element of our sample and the sample mean, then divided by the sample size-1 or n-1.

We divide by n-1 when calculating the sample variance (and not by n as any average) to make the sample variance a good estimator of the true population variance.

If you have population data, you will divide by N (where N is the population size) to get the variance.

### – Example

We have a population of more than 20,000 individuals. From the census data, the true population variance for the age was 298.84 years^2.

We take a random sample of 50 individuals from this data. The sum of squared differences from the mean was 12112.08.

If we divide by 50 (sample size), the variance will be 242.24, while if we divide by 49 (sample size-1), the variance will be 247.19.

Dividing by n-1 prevents the sample variance from underestimating the true population variance.

## The role of the sample variance

**The sample variance** is a summary statistic that can be used to deduce the spread of the population from which the sample was randomly selected.

In the above example about Google and Facebook stock prices, although we have only a sample of 50 days, we can conclude (with some level of certainty) Google stock is more variable (riskier) than Facebook stock.

Variance is important in an investment where we can use it (as a measure of spread or variability) as a measure of risk.

We see in the above example that although Google stock has a higher closing price, it is more variable and so more risky to invest in.

Another example is when the product produced from some machines is with high variance in the industrial machines. It indicates that these machines need adjustment.

### Disadvantages of variance as a measure of spread:

- It is affected by outliers. These are the numbers that are far from the mean. Squaring the differences between these numbers and the mean can skew the variance.
- Not easily interpreted because the variance has the squared unit of the data.

We use the variance to take the square root of its value, which indicates the standard deviation of the data set. Thus, the standard deviation has the same unit as the original data, so it is more easily interpreted.

### Practice questions

1. The following table is the daily closing prices (in USD) of two stocks from the financial sector, JP Morgan Chase (JPM) and Citigroup (C), for some days in 2011. Which stock has a more variable closing stock price?

Date | JP Morgan | Citigroup |

2011-06-01 | 41.76 | 39.65 |

2011-06-02 | 41.61 | 40.01 |

2011-06-03 | 41.57 | 39.85 |

2011-06-06 | 40.53 | 38.07 |

2011-06-07 | 40.72 | 37.58 |

2011-06-08 | 40.39 | 36.81 |

2011-06-09 | 40.98 | 37.77 |

2011-06-10 | 41.05 | 37.92 |

2011-06-13 | 41.67 | 39.17 |

2011-06-14 | 41.61 | 38.78 |

2011-06-15 | 40.68 | 38.00 |

2011-06-16 | 40.36 | 37.63 |

2011-06-17 | 40.80 | 38.30 |

2011-06-20 | 40.48 | 38.16 |

2011-06-21 | 40.91 | 39.31 |

2011-06-22 | 40.69 | 39.51 |

2011-06-23 | 40.07 | 39.41 |

2011-06-24 | 39.49 | 39.59 |

2011-06-27 | 39.88 | 39.99 |

2011-06-28 | 39.54 | 40.15 |

2011-06-29 | 40.45 | 41.50 |

2011-06-30 | 40.94 | 41.64 |

2011-07-01 | 41.58 | 42.88 |

2011-07-05 | 41.03 | 42.57 |

2011-07-06 | 40.56 | 42.01 |

2011-07-07 | 41.32 | 42.63 |

2011-07-08 | 40.74 | 42.03 |

2011-07-11 | 39.43 | 39.79 |

2011-07-12 | 39.39 | 39.07 |

2011-07-13 | 39.62 | 39.47 |

2. The following is a table of the compressive strengths for 25 concrete samples (in pound per square inch or psi) produced from 3 different machines. Which machine is more precise in its production?

**Note** more precise means less variable.

machine_1 | machine_2 | machine_3 |

12.55 | 26.86 | 66.70 |

37.68 | 53.30 | 28.47 |

76.80 | 23.25 | 21.86 |

25.12 | 20.08 | 28.80 |

12.45 | 15.34 | 26.91 |

36.80 | 37.44 | 64.90 |

48.40 | 15.69 | 11.85 |

59.80 | 23.69 | 31.87 |

48.15 | 37.27 | 15.09 |

39.23 | 44.61 | 52.42 |

40.86 | 64.90 | 77.30 |

42.33 | 10.22 | 48.67 |

46.23 | 25.51 | 29.65 |

19.35 | 29.79 | 37.68 |

32.04 | 11.47 | 50.46 |

35.17 | 23.79 | 24.28 |

31.35 | 28.63 | 39.30 |

6.28 | 30.12 | 33.36 |

40.06 | 8.06 | 28.63 |

40.60 | 33.80 | 35.75 |

33.72 | 32.25 | 35.10 |

46.64 | 55.64 | 6.47 |

29.89 | 71.30 | 37.42 |

16.50 | 67.11 | 12.64 |

30.45 | 40.06 | 51.26 |

3. The following is a table for the variance in weights of diamonds produced from 4 different machines and a dot plot for the individual weight values.

machine | variance |

machine_1 | 0.2275022 |

machine_2 | 0.3267417 |

machine_3 | 0.1516739 |

machine_4 | 0.1873904 |

We see that machine_3 has the least variance. Knowing that, which dots are most likely produced from machine_3?

4. The following is the variance for different stocks closing prices (from the same sector). Which stock is safer to invest in?

symbol2 | variance |

stock_1 | 30820.2059 |

stock_2 | 971.7809 |

stock_3 | 31816.9763 |

stock_4 | 26161.1889 |

5. The following dot plot is for the daily Ozone measurements in New York, May to September 1973. Which month is the most variable in Ozone measurements, and which month is the least variable?

### Answer key

1. We will calculate the variance for each stock then compare between them.

*The variance of JP Morgan Chase stock closing price is calculated as follows:*

- Add up all of the numbers:

Sum = 1219.85.

- Count the numbers of items in your sample. In this sample, there are 30 items.
- Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 1219.85/30 = 40.66167.

- Subtract the mean from each value of your sample and square the difference.

JP Morgan | stock-mean | squared difference |

41.76 | 1.0983 | 1.21 |

41.61 | 0.9483 | 0.90 |

41.57 | 0.9083 | 0.83 |

40.53 | -0.1317 | 0.02 |

40.72 | 0.0583 | 0.00 |

40.39 | -0.2717 | 0.07 |

40.98 | 0.3183 | 0.10 |

41.05 | 0.3883 | 0.15 |

41.67 | 1.0083 | 1.02 |

41.61 | 0.9483 | 0.90 |

40.68 | 0.0183 | 0.00 |

40.36 | -0.3017 | 0.09 |

40.80 | 0.1383 | 0.02 |

40.48 | -0.1817 | 0.03 |

40.91 | 0.2483 | 0.06 |

40.69 | 0.0283 | 0.00 |

40.07 | -0.5917 | 0.35 |

39.49 | -1.1717 | 1.37 |

39.88 | -0.7817 | 0.61 |

39.54 | -1.1217 | 1.26 |

40.45 | -0.2117 | 0.04 |

40.94 | 0.2783 | 0.08 |

41.58 | 0.9183 | 0.84 |

41.03 | 0.3683 | 0.14 |

40.56 | -0.1017 | 0.01 |

41.32 | 0.6583 | 0.43 |

40.74 | 0.0783 | 0.01 |

39.43 | -1.2317 | 1.52 |

39.39 | -1.2717 | 1.62 |

39.62 | -1.0417 | 1.09 |

- Add up all of the squared differences you found in Step 4.

Sum = 14.77.

- Divide the number you get in step 5 by sample size-1 to get the variance. We have 30 numbers, so the sample size is 30.

The variance of JPM stock closing price = 14.77/(30-1) = 0.51 USD^2.

*The variance of Citigroup stock closing price is calculated as follows:*

- Add up all of the numbers:

Sum = 1189.25.

- Count the numbers of items in your sample. In this sample, there are 30 items.
- Divide the number you found in step 1 by the number you found in step 2.

Тhe sample mean = 1189.25/30 = 39.64167.

- Subtract the mean from each value of your sample and square the difference.

Citigroup | stock-mean | squared difference |

39.65 | 0.0083 | 0.00 |

40.01 | 0.3683 | 0.14 |

39.85 | 0.2083 | 0.04 |

38.07 | -1.5717 | 2.47 |

37.58 | -2.0617 | 4.25 |

36.81 | -2.8317 | 8.02 |

37.77 | -1.8717 | 3.50 |

37.92 | -1.7217 | 2.96 |

39.17 | -0.4717 | 0.22 |

38.78 | -0.8617 | 0.74 |

38.00 | -1.6417 | 2.70 |

37.63 | -2.0117 | 4.05 |

38.30 | -1.3417 | 1.80 |

38.16 | -1.4817 | 2.20 |

39.31 | -0.3317 | 0.11 |

39.51 | -0.1317 | 0.02 |

39.41 | -0.2317 | 0.05 |

39.59 | -0.0517 | 0.00 |

39.99 | 0.3483 | 0.12 |

40.15 | 0.5083 | 0.26 |

41.50 | 1.8583 | 3.45 |

41.64 | 1.9983 | 3.99 |

42.88 | 3.2383 | 10.49 |

42.57 | 2.9283 | 8.57 |

42.01 | 2.3683 | 5.61 |

42.63 | 2.9883 | 8.93 |

42.03 | 2.3883 | 5.70 |

39.79 | 0.1483 | 0.02 |

39.07 | -0.5717 | 0.33 |

39.47 | -0.1717 | 0.03 |

- Add up all of the squared differences you found in step 4.

Sum = 80.77.

- Divide the number you get in step 5 by sample size-1 to get the variance. We have 30 numbers, so the sample size is 30.

Citigroup stock closing price variance = 80.77/(30-1) = 2.79 USD^2, while the variance of JP Morgan Chase stock closing price is only 0.51 USD^2.

The Citigroup stock closing price is more variable. We can see that if we plot the data as a dot plot.

When the x-axis is common, we see that the Citigroup prices are more scattered than JP Morgan prices.

2. We will calculate the variance for each machine then compare them.

*The variance of machine_1 is calculated as follows:*

- Add up all of the numbers:

Sum = 888.45.

- Count the numbers of items in your sample. In this sample, there are 25 items.
- Divide the number you found in step 1 by the number you found in step 2.

The sample mean = 888.45/25 = 35.538.

- Subtract the mean from each value of your sample and square the difference.

machine_1 | strength-mean | squared difference |

12.55 | -22.988 | 528.45 |

37.68 | 2.142 | 4.59 |

76.80 | 41.262 | 1702.55 |

25.12 | -10.418 | 108.53 |

12.45 | -23.088 | 533.06 |

36.80 | 1.262 | 1.59 |

48.40 | 12.862 | 165.43 |

59.80 | 24.262 | 588.64 |

48.15 | 12.612 | 159.06 |

39.23 | 3.692 | 13.63 |

40.86 | 5.322 | 28.32 |

42.33 | 6.792 | 46.13 |

46.23 | 10.692 | 114.32 |

19.35 | -16.188 | 262.05 |

32.04 | -3.498 | 12.24 |

35.17 | -0.368 | 0.14 |

31.35 | -4.188 | 17.54 |

6.28 | -29.258 | 856.03 |

40.06 | 4.522 | 20.45 |

40.60 | 5.062 | 25.62 |

33.72 | -1.818 | 3.31 |

46.64 | 11.102 | 123.25 |

29.89 | -5.648 | 31.90 |

16.50 | -19.038 | 362.45 |

30.45 | -5.088 | 25.89 |

- Add up all of the squared differences you found in Step 4.

Sum = 5735.17.

- Divide the number you get in step 5 by sample size-1 to get the variance. We have 25 numbers, so the sample size is 25.

The variance of machine_1 = 5735.17/(25-1) = 238.965 psi^2.

With similar calculations, the variance of machine_2 = 315.6805 psi^2, and the variance for machine_3 = 310.7079 psi^2.

The machine_1 is more precise or less variable in the compressive strength of concrete produced.

3. Blue dots because they are more compact than other dot groups.

4. Stock_2 because it has the least variance.

5. The most variable month is 8 or August and the least variable month is 6 or June.