# Variance

Variance is another statistical tool which tells how much a data is diverging from the mean. It is the mean of the squared differences. Where the differences refer to the difference between the mean and the individual values. Its scale is in the range of square of the maximum value.

We need variance when we need to know how much a data is spread out. Average of a data cannot tell how much the data is close or spread out. It cannot even know whether the whole data is just the same. For instance, 3,3,3,3,3 has mean 3. Hence variance or standard deviation enables us to perceive how much wide is the data.

## Formula and Calculation

$$\sigma^\text{2}=\ \frac{\sum _ {\text{i}=\text{1}}^{\text{n}}\left(\text{x} _ \text{i}-\mu\right)^\text{2}}{\text{n}}$$

Where, σ is standard deviation, n is the number of values, μ is the mean and xi is ith value.

The steps required to calculate variance may include.

1. Find mean.
2. Find the squares of differences between the mean and the individual values.
3. Mean of the squared differences.

Standard deviation(σ) is the square root of variance.

### Sample vs Population Variance

While dealing with sample data, since we are unsure about the correctness, we introduce some margin by dividing squared differences by n-1 or n-2 instead of n itself. It increases the value of variance and we feel safe.

Sample Variance Formula:

$$\sigma^\text{2}=\ \frac{\sum _ {\text{i}=\text{1}}^{\text{n}}\left(\text{x} _ \text{i}-\mu\right)^\text{2}}{\text{n}-\text{1}}$$

or

$$\sigma^\text{2}=\ \frac{\sum _ {\text{i}=\text{1}}^{\text{n}}\left(\text{x} _ \text{i}-\mu\right)^\text{2}}{\text{n}-\text{2}}$$

## Example

The following table shows the stock price of Apple. Let us calculate its variance to know the variation which can occur in a day.

Date Apple Stock Price
(\$)
Return
(%)
Difference
(xi−μ)
* Squared Differences
(xi−μ)2
1/1/2017 121.35 12.89 -31.85 1,014.72
2/1/2017 136.99 4.87 -16.21 262.91
3/1/2017 143.66 -0.01 -9.54 91.10
4/1/2017 143.65 6.34 -9.55 91.29
5/1/2017 152.76 -5.72 -0.44 0.20
6/1/2017 144.02 3.27 -9.18 84.36
7/1/2017 148.73 10.27 -4.47 20.02
8/1/2017 164.00 -6.02 10.80 116.54
9/1/2017 154.12 9.68 0.92 0.84
10/1/2017 169.04 1.66 15.84 250.76
11/1/2017 171.85 -1.52 18.65 347.65
12/1/2017 169.23 1.79 16.03 256.81
1/1/2018 172.26 19.06 363.11

Step 1: Mean of the stock price = 153.20

Step 2 *

Step 3: Mean of the squared differences(xi−μ)2 A.K.A. variance = 223.10

For sample data the variance is 241.69.