How to Calculate Mean and Standard Deviation (Step by Step)

There are two versions of the standard deviation formula, your lecturer used one, your textbook uses the other, and nobody has explained which one your assignment wants. If that is why you are here, this guide fixes it in about four minutes.

We will calculate the mean and standard deviation from scratch with a real data set, settle the n versus n−1 question properly, and show you how to check your own working. If you just need the numbers, our Mean and Standard Deviation Calculator shows every step, not only the result.

Start With the Mean (The Easy Part)

The mean is the average. Add everything up, divide by how many there are.

Mean (x̄) = Σx ÷ n

Our data set — five test scores: 4, 8, 6, 5, 3

Sum = 4 + 8 + 6 + 5 + 3 = 26
Count = 5
Mean = 26 ÷ 5 = 5.2

Done. The mean tells you the centre of your data. What it does not tell you is whether your data is tightly clustered around 5.2 or scattered wildly — and that is exactly the gap standard deviation fills.

What Standard Deviation Actually Measures

Before the formula, understand the question it answers: on average, how far is each value from the mean?

Two classes can both average 70% on a test. In one, everyone scored between 68 and 72. In the other, half scored 40 and half scored 100. Same mean, completely different reality. Standard deviation is the number that tells them apart.

Small standard deviation = data clustered near the mean.
Large standard deviation = data spread out.

The Formula, and Why It Looks Like That

s = √( Σ(x − x̄)² ÷ (n − 1) )

It looks intimidating. It is actually four small steps, and each one exists for a reason:

1. Find each deviation (x − x̄). How far is this value from the mean?
2. Square each one. Why? Because deviations above and below the mean would otherwise cancel out to exactly zero, every single time. Squaring makes them all positive.
3. Average the squares. This gives the variance.
4. Take the square root. Squaring inflated the units (marks became marks-squared), so the root brings you back to the original units.

Every step is undoing a problem the previous step created. It is not arbitrary.

Full Worked Example

Data: 4, 8, 6, 5, 3. Mean = 5.2.

Step 1 — deviations from the mean:
4 − 5.2 = −1.2
8 − 5.2 =  2.8
6 − 5.2 =  0.8
5 − 5.2 = −0.2
3 − 5.2 = −2.2

Quick check: these should sum to zero. −1.2 + 2.8 + 0.8 − 0.2 − 2.2 = 0. They do — which confirms your mean is right. Use this check every time.

Step 2 — square them:
(−1.2)² = 1.44
(2.8)² = 7.84
(0.8)² = 0.64
(−0.2)² = 0.04
(−2.2)² = 4.84

Step 3 — sum the squares:
1.44 + 7.84 + 0.64 + 0.04 + 4.84 = 16.8

Step 4 — divide (this is the n vs n−1 moment):
Sample: 16.8 ÷ (5 − 1) = 16.8 ÷ 4 = 4.2 ← this is the sample variance
Population: 16.8 ÷ 5 = 3.36 ← this is the population variance

Step 5 — square root:
Sample standard deviation: √4.2 = 2.05
Population standard deviation: √3.36 = 1.83

Same data. Two different answers. This is why students get marked wrong on work that is otherwise perfect.

n or n−1? Settle It Once

Ask one question: is this data everything, or a sample of something bigger?

Use n (population) when your data is the whole group. Every student in your class, and the class is what you care about. Nothing is being estimated.

Use n−1 (sample) when your data is a subset used to say something about a larger group. 50 students surveyed to describe the whole university.

Why subtract 1? Because a sample almost always underestimates the true spread of the population it came from — your sample happened to miss the most extreme values simply because they are rare. Dividing by a smaller number makes the answer slightly larger, correcting that bias. It is called Bessel’s correction, and it is not a trick; it is a repair.

When in doubt, use n−1. Most real-world data is a sample, most statistics courses default to it, and most calculators label it “s” or “σn−1“. If your assignment does not say, sample is the safer assumption — but it costs you nothing to ask your lecturer, and it is a perfectly reasonable question.

Mistakes That Cost Marks

Rounding the mean too early. If your mean is 5.238 and you round to 5.2 before calculating deviations, that error compounds through every squared term. Keep full precision until the very last step.

Forgetting the square root. If you stop at step 4 you have reported the variance, not the standard deviation. Easy to do under exam pressure, and it looks like you do not know the difference.

Mixing up σ and s. σ (sigma) is the population standard deviation; s is the sample. Using the wrong symbol suggests you used the wrong formula even when you did not.

Losing a negative when squaring. (−2.2)² = +4.84, not −4.84. Every squared deviation must be positive. If one is not, you have a sign error.

Reading the Result

Our sample standard deviation was 2.05 with a mean of 5.2. So typical scores sit roughly 2 marks either side of 5.2 — somewhere around 3.15 to 7.25. Look back at the data (4, 8, 6, 5, 3) and that describes it well.

For roughly normal data, a useful rule of thumb: about 68% of values fall within one standard deviation of the mean, and about 95% within two. It is what makes standard deviation genuinely useful rather than just another number to compute.

Check Your Working

Enter your data into our free Mean and Standard Deviation Calculator and it returns the mean, variance and standard deviation for both sample and population, with the steps shown. Comparing it against your hand calculation is the fastest way to find exactly which step went wrong — which is how the method actually sticks.

Frequently Asked Questions

How do you calculate the mean and standard deviation?

Add all values and divide by the count to get the mean. Then subtract the mean from each value, square the results, add them up, divide by n−1 for a sample (or n for a population), and take the square root.

Should I divide by n or n−1?

Use n−1 when your data is a sample representing a larger group, and n when your data is the entire population. If your assignment does not specify, n−1 is the safer default because most data is a sample.

What is the difference between variance and standard deviation?

Variance is the average of the squared deviations. Standard deviation is its square root. The square root matters because it returns the answer to the original units — variance is in squared units, which is not meaningful on its own.

Why do we square the deviations?

Because deviations above and below the mean always cancel to exactly zero. Squaring makes every deviation positive so they accumulate instead of cancelling, and it also weights larger deviations more heavily.

What does a high standard deviation mean?

The data is spread widely around the mean. A low standard deviation means values cluster tightly near it. Two data sets can share a mean and be completely different in this respect.

Can standard deviation be negative?

No. It comes from a square root of squared values, so it is always zero or positive. A standard deviation of exactly zero means every value in the data set is identical. If you get a negative, you have made a sign error.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top