Standard deviation formula, step by step
Standard deviation is the typical distance of the values in a data set from their mean. A small one means the values cluster near the mean, a large one means they are spread out. You find it by averaging the squared distances from the mean and taking a square root, and the only choice is whether to divide that average by N or by N minus 1.
For students and parents planning test prep or coursework: one hour with George Li, one to one by video, is $180, $200 or $160, by subject. You leave with a written plan within one working day.
Book your first session| Feature | Population | Sample |
|---|---|---|
| Data you have | every member of the group | some members of a larger group |
| Symbol | σ | s |
| Divide the sum of squares by | N | n − 1 |
| Typical use | all the scores in one class | a survey of part of a town |
mu is the mean of a whole population and xbar is the mean of a sample. The squared distances are summed in both cases.
Standard statistics definitions, restated by us
- Population:
sigma = sqrt( sum of (x - mu)^2 / N ) - Sample:
s = sqrt( sum of (x - xbar)^2 / (n - 1) )
What are the steps for a population?
- Find the mean of the data.
- Subtract the mean from every value to get the distances.
- Square each distance, so negatives cannot cancel positives.
- Add the squares.
- Divide by N, the count of values. This number is the variance.
- Finish by taking the square root of that variance.
Worked example. The eight values are 2, 4, 4, 4, 5, 5, 7 and 9, and they are the whole population. Their sum is 40, so the mean is 40 ÷ 8 = 5. The distances from 5 are −3, −1, −1, −1, 0, 0, 2 and 4. Squared, they are 9, 1, 1, 1, 0, 0, 4 and 16, which add to 32. The variance is 32 ÷ 8 = 4, and its square root is 2.
Answer: the population standard deviation is 2. Check: the values lie between 2 and 9 around a center of 5, and a typical distance of 2 is believable.
What changes for a sample?
Only step 5: divide by n − 1 instead of n. A sample tends to sit a little closer to its own mean than to the true mean of the larger group, so dividing by n would run slightly small. Using n − 1 corrects for that.
Worked example. A sample has five values: 6, 8, 10, 12 and 14. The mean is 50 ÷ 5 = 10. The distances are −4, −2, 0, 2 and 4, and their squares are 16, 4, 0, 4 and 16, which add to 40. Divide by n − 1 = 4 to get 10, and take the square root: about 3.16.
Answer: s ≈ 3.16. For comparison, treating the same five numbers as a whole population gives 40 ÷ 5 = 8 and a square root of about 2.83. The sample version is larger, and the gap shrinks as n grows.
How do you choose between the two?
Ask whether your numbers are the entire group you care about. The scores of every student in one class, if the question is about that class, make a population. A poll of 400 residents, used to say something about a whole city, is a sample. When a problem does not say, a statement such as "a random sample of" points to the n − 1 version, and "all" or "every" points to N. Most graphing calculators report both numbers after a one-variable statistics run, so read the label before you copy one.
What does the number mean?
It is in the same units as the data. If the values are lengths in millimeters, the standard deviation is in millimeters, while the variance is in square millimeters, which is why the square root is taken. Two data sets can have the same mean and very different spreads: 4, 5, 5, 6 and 1, 5, 5, 9 both average 5, but the first has the smaller deviation.
What mistakes should you watch for?
- Adding the raw distances instead of the squared ones. They always add to zero around the mean.
- Dividing by the wrong count. Decide first whether you have a population or a sample.
- Stopping at the variance and forgetting the square root.
- Rounding the mean and carrying the error through every distance. Keep exact values until the end.
- Making an arithmetic slip in one square. Check the sum of the distances, which must be zero, before squaring.
When does a tutor help with statistics?
A tutor helps when the formula is clear but a long set of numbers keeps producing slips, since a tidy table with a column for each step usually ends that. See the college courses page, the packages, or book a first session.
Common questions
What is standard deviation?
It is the typical distance between the data values and their mean, found as the square root of the average squared distance.
When do you divide by n − 1?
When the data are a sample from a larger group. Dividing by n − 1 corrects for a sample's tendency to underestimate the spread.
What is the difference between variance and standard deviation?
Variance is the average squared distance from the mean. Standard deviation is its square root, so it matches the units of the data.
Can a standard deviation be negative?
No. It is a square root of an average of squares, so it is zero or positive, and it is zero only when every value is identical.