A standard deviation is a statistic that measures the dispersion of a dataset relative to its mean.

Symbol of standard deviation is **σ** (the Greek letter Sigma)

Standard Deviation is also calculated as thesquare rootof theVariance.What is variance and how to calculate it? CheckHERE

It is calculated as the square root of variance by determining each data point’s deviation relative to the mean. If the data points are further from the mean, there is a higher deviation within the data set. Thus, the more spread out the data, the higher the standard deviation.

To calculate the standard deviation follow these steps:

**Step 1:**Find the Mean (the simple average of the numbers)**Step 2:**Subtract the Mean from each number**Step 3:**Square the Result (the*squared difference*) and take sum**Step 4:**Take the average of squared differences.- Above 4 steps are similar, for both variance and standard deviation.

**Step 5:**Take square root of Variance.

Table of Contents

## Example

Data = 8, 9, 10, 11, 12

**Step 1:**Find the Mean (the simple average of the numbers)- Mean: (8 + 9 + 10 + 11 + 12) ÷ 5 = 10

**Step 2:**Subtract the Mean from each number

Score | Deviation from the mean |
---|---|

8 | 8 – 10 = -2 |

9 | 9 – 10 = 1 |

10 | 10 – 10 = 0 |

11 | 11 – 10 = 1 |

12 | 15 – 10 = 5 |

**Step 3**: Square each deviation from the mean and take sum- (-2)
^{2}+ (1)^{2}+ (0)^{2}+ (1)^{2}+ (2)^{2}=**10**

- (-2)
**Step 4:**Divide the sum of squares by*n – 1*or*N*- Divide the sum of the squares by
*n*– 1 (for a sample) or*N*(for a population). - Since we’re working with a sample, we’ll use
*n*– 1, where*n*= 5. - 10/(5-1) =
**2.5**

- Divide the sum of the squares by
**Step 5:**Take square root of Variance.- √ 2.5 =
**1.58**

- √ 2.5 =

## Drawback

The biggest drawback of using standard deviation is that it can be impacted by outliers and extreme values. Standard deviation assumes a normal distribution and calculates all uncertainty as risk, even when it’s in the investor’s favor—such as above-average returns.

## Video

## Code

Starting Python 3.4, the standard library comes with the *stdev function (sample std. dev or std. dev n-1) *as part of the

**statistics**module:

```
# Python code
# stdev() function of Statistics Module
# Import statistics module
import statistics
# Creating a sample of data
sample = [8, 9, 10, 11, 12]
# Print Standard Deviation of the sample set
print(f"Standard Deviation of sample set is {statistics.stdev(sample)}")
```

Standard Deviation of sample set is1.58

The *population std. dev *(or *std. dev n*) can be obtained using the *pstdev function*:

```
# Python code
# pstdev() function of Statistics Module
# Import statistics module
import statistics
# Creating a sample of data
population = [8, 9, 10, 11, 12]
# Print Standard Deviation of the sample set
print(f"Standard Deviation of population set is {statistics.pstdev(population)}")
```

Standard Deviation of population set is1.41