If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Calculating standard deviation step by step

## Introduction

In this article, we'll learn how to calculate standard deviation "by hand".
Interestingly, in the real world no statistician would ever calculate standard deviation by hand. The calculations involved are somewhat complex, and the risk of making a mistake is high. Also, calculating by hand is slow. Very slow. This is why statisticians rely on spreadsheets and computer programs to crunch their numbers.
So what's the point of this article? Why are we taking time to learn a process statisticians don't actually use? The answer is that learning to do the calculations by hand will give us insight into how standard deviation really works. This insight is valuable. Instead of viewing standard deviation as some magical number our spreadsheet or computer program gives us, we'll be able to explain where that number comes from.

## Overview of how to calculate standard deviation

The formula for standard deviation (SD) is
start text, S, D, end text, equals, square root of, start fraction, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, mu, close vertical bar, squared, divided by, N, end fraction, end square root
where sum means "sum of", x is a value in the data set, mu is the mean of the data set, and N is the number of data points in the population.
The standard deviation formula may look confusing, but it will make sense after we break it down. In the coming sections, we'll walk through a step-by-step interactive example. Here's a quick preview of the steps we're about to follow:
Step 1: Find the mean.
Step 2: For each data point, find the square of its distance to the mean.
Step 3: Sum the values from Step 2.
Step 4: Divide by the number of data points.
Step 5: Take the square root.

## An important note

The formula above is for finding the standard deviation of a population. If you're dealing with a sample, you'll want to use a slightly different formula (below), which uses n, minus, 1 instead of N. The point of this article, however, is to familiarize you with the process of computing standard deviation, which is basically the same no matter which formula you use.
start text, S, D, end text, start subscript, start text, s, a, m, p, l, e, end text, end subscript, equals, square root of, start fraction, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, x, with, \bar, on top, close vertical bar, squared, divided by, n, minus, 1, end fraction, end square root

## Step-by-step interactive example for calculating standard deviation

First, we need a data set to work with. Let's pick something small so we don't get overwhelmed by the number of data points. Here's a good one:
6, comma, 2, comma, 3, comma, 1

### Step 1: Finding $\goldD{\mu}$start color #e07d10, mu, end color #e07d10 in $\sqrt{\dfrac{\sum\limits_{}^{}{{\lvert x-\goldD{\mu}\rvert^2}}}{N}}$square root of, start fraction, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, start color #e07d10, mu, end color #e07d10, close vertical bar, squared, divided by, N, end fraction, end square root

In this step, we find the mean of the data set, which is represented by the variable mu.
Fill in the blank.
mu, equals

### Step 2: Finding $\goldD{\lvert x - \mu \rvert^2}$start color #e07d10, open vertical bar, x, minus, mu, close vertical bar, squared, end color #e07d10 in $\sqrt{\dfrac{\sum\limits_{}^{}{\goldD{{\lvert x-\mu}\rvert^2}}}{N}}$square root of, start fraction, sum, start subscript, end subscript, start superscript, end superscript, start color #e07d10, open vertical bar, x, minus, mu, close vertical bar, squared, end color #e07d10, divided by, N, end fraction, end square root

In this step, we find the distance from each data point to the mean (i.e., the deviations) and square each of those distances.
For example, the first data point is 6 and the mean is 3, so the distance between them is 3. Squaring this distance gives us 9.
Complete the table below.
Data point xSquare of the distance from the mean open vertical bar, x, minus, mu, close vertical bar, squared
69
2
3
1

### Step 3: Finding $\goldD{\sum\lvert x - \mu \rvert^2}$start color #e07d10, sum, open vertical bar, x, minus, mu, close vertical bar, squared, end color #e07d10 in $\sqrt{\dfrac{\goldD{\sum\limits_{}^{}{{\lvert x-\mu}\rvert^2}}}{N}}$square root of, start fraction, start color #e07d10, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, mu, close vertical bar, squared, end color #e07d10, divided by, N, end fraction, end square root

The symbol sum means "sum", so in this step we add up the four values we found in Step 2.
Fill in the blank.
sum, open vertical bar, x, minus, mu, close vertical bar, squared, equals

### Step 4: Finding $\goldD{\dfrac{\sum\lvert x - \mu \rvert^2}{N}}$start color #e07d10, start fraction, sum, open vertical bar, x, minus, mu, close vertical bar, squared, divided by, N, end fraction, end color #e07d10 in $\sqrt{\goldD{\dfrac{\sum\limits_{}^{}{{\lvert x-\mu}\rvert^2}}{N}}}$square root of, start color #e07d10, start fraction, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, mu, close vertical bar, squared, divided by, N, end fraction, end color #e07d10, end square root

In this step, we divide our result from Step 3 by the variable N, which is the number of data points.
Fill in the blank.
start fraction, sum, open vertical bar, x, minus, mu, close vertical bar, squared, divided by, N, end fraction, equals

### Step 5: Finding the standard deviation $\sqrt{\dfrac{\sum\limits_{}^{}{{\lvert x-\mu\rvert^2}}}{N}}$square root of, start fraction, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, mu, close vertical bar, squared, divided by, N, end fraction, end square root

We're almost finished! Just take the square root of the answer from Step 4 and we're done.
Fill in the blank.
start text, S, D, end text, equals, square root of, start fraction, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, mu, close vertical bar, squared, divided by, N, end fraction, end square root, approximately equals

Yes! We did it! We successfully calculated the standard deviation of a small data set.

### Summary of what we did

We broke down the formula into five steps:
Step 1: Find the mean mu.
mu, equals, start fraction, 6, plus, 2, plus, 3, plus, 1, divided by, 4, end fraction, equals, start fraction, 12, divided by, 4, end fraction, equals, start color #11accd, 3, end color #11accd
Step 2: Find the square of the distance from each data point to the mean open vertical bar, x, minus, mu, close vertical bar, squared.
xopen vertical bar, x, minus, mu, close vertical bar, squared
6open vertical bar, 6, minus, start color #11accd, 3, end color #11accd, close vertical bar, squared, equals, 3, squared, equals, 9
2open vertical bar, 2, minus, start color #11accd, 3, end color #11accd, close vertical bar, squared, equals, 1, squared, equals, 1
3open vertical bar, 3, minus, start color #11accd, 3, end color #11accd, close vertical bar, squared, equals, 0, squared, equals, 0
1open vertical bar, 1, minus, start color #11accd, 3, end color #11accd, close vertical bar, squared, equals, 2, squared, equals, 4
Steps 3, 4, and 5:
\begin{aligned} \text{SD} &= \sqrt{\dfrac{\sum\limits_{}^{}{{\lvert x-\mu\rvert^2}}}{N}}\\\\\\\\ &= \sqrt{\dfrac{9 + 1 + 0 + 4}{4}} \\\\\\\\ &= \sqrt{\dfrac{{14}}{4}} ~~~~~~~~\small \text{Sum the squares of the distances (Step 3).} \\\\\\\\ &= \sqrt{{3.5}} ~~~~~~~~\small \text{Divide by the number of data points (Step 4).} \\\\\\\\ &\approx 1.87 ~~~~~~~~\small \text{Take the square root (Step 5).} \end{aligned}

## Try it yourself

Here's a reminder of the formula:
start text, S, D, end text, equals, square root of, start fraction, sum, start subscript, end subscript, start superscript, end superscript, open vertical bar, x, minus, mu, close vertical bar, squared, divided by, N, end fraction, end square root
And here's a data set:
1, comma, 4, comma, 7, comma, 2, comma, 6
Find the standard deviation of the data set.