# Standard Deviation

Standard deviation is the tendency of a data to differ from the mean and from each other. Mean, median and mod estimate the midpoint of the data but standard deviation tells how much the data is spread out.

Our goal is to find a way to measure the tendency of the data to diverge. We could’ve just taken the mean of the differences between the mean and each number, but its behavior is not what we want. Consider 3, −2, −1 whose mean of differences is 0. If we use absolute values, it can give the same result for multiple data sets which may not be equally diverged.

If we use the square of the differences. It has two benefits.

• x2 remains positive for all values. (even function)
• The value of x2 increases faster for greater values. Hence if the data has more points in extremes the mean of x2 will be greater.

The mean of the squared differences is called variance and the value of variance can go beyond the range of the data. So, we take the square root of the variance which gives us standard deviation whose value remains in the range.

## Formula and Calculation

Standard deviation is the square root of the variance.

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

Where μ is mean and n is the number of values.

Breaking down the formula, standard deviation can be calculated in the following steps.

1. Calculate the mean.
2. Find out square of the differences between the numbers and mean. (xi − μ)2
3. Find the variance which is the mean of (xi − μ)2 for all the values.
4. Find out the standard deviation be taking square root of the variance.

### Sample vs Population Standard Deviation

There are two types of standard deviation which are the result of precautions while working with sample data. The types are Sample and Population Standard Deviation. For Sample Standard Deviation we use n-1 or n-2 instead of n while dividing the mean of differences. This increases the value of standard deviation which is good while working on a part of the original data.

Sample Standard Deviation Formula:

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

or

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

## Example

The following table shows the stock price of Google. Let us calculate the standard deviation of the the stock price to know how much it can vary.

Date Stock Price
($) Return (%) Difference (xi−μ) Squared Differences (xi−μ)2 01/01/2017 796.79 0.03 -150.32 22,596.34 02/01/2017 823.21 0.01 -123.90 15,351.40 03/01/2017 829.56 0.09 -117.55 13,818.18 04/01/2017 905.96 0.07 -41.15 1,693.38 05/01/2017 964.86 -0.06 17.75 315.03 06/01/2017 908.73 0.02 -38.38 1,473.08 07/01/2017 930.50 0.01 -16.61 275.92 08/01/2017 939.33 0.02 -7.78 60.54 09/01/2017 959.11 0.06 12.00 143.98 10/01/2017 1,016.64 0.00 69.53 4,834.32 11/01/2017 1,021.41 0.02 74.30 5,520.37 12/01/2017 1,046.40 0.12 99.29 9,858.36 01/01/2018 1,169.94 222.83 49,652.87 Step 1: Mean of the stock price = 947.11 Step 2: Calculate (xi−μ)2 Step 3: Mean of the squared differences(xi−μ)2 also known as variance = 9661 Step 4: Standard deviation(square root of variance) = 98.29 So it tells that the stock price can go vary upto$98.29 from the mean. You can see that variance cannot be used like \$9661 since its value is not in the range of the data and not easily analyzable.

Considering the above data a sample, the standard deviation will be 102.3.