You calculate the mean by summing every value and dividing by how many values you have, then calculate standard deviation by measuring how far each value sits from that mean, squaring those distances, averaging them, and taking the square root. The one decision that changes your answer is whether the data is a full population or a sample β divide by N for a population, by N β 1 for a sample. Everything else in this article is arithmetic you can do on paper, in Excel, or in a spreadsheet-free calculator.
The worked example running through this article is deliberately small so you can check every step by hand. Here is the data set: 4, 8, 6, 5, 3. Five values. If you follow the steps below, you should land on a sample mean of 5.2 and a sample standard deviation of about 1.92. If your numbers differ, the section on the N versus N β 1 mistake will tell you where you went wrong.
Defining Each Symbol Before Touching a Calculator
The mean, written as xΜ for a sample or ΞΌ for a population, is the arithmetic average: add up all values, divide by the count. In notation that's xΜ = Ξ£x Γ· n, where Ξ£x means "the sum of every value" and n is how many values there are. That single number becomes the reference point for everything else in the calculation, which is why an error here poisons the whole result.
Standard deviation, written as s for a sample or Ο for a population, measures the typical distance between a value and the mean. It's expressed in the same units as your data, so if you're measuring heights in centimetres, the standard deviation is also in centimetres. That makes it directly interpretable in a way that variance (the squared version) is not. Variance is the intermediate step, not the answer most people want.
| Symbol | What it means | Example from the data set 4, 8, 6, 5, 3 |
|---|---|---|
| n | Number of values | 5 |
| Ξ£x | Sum of all values | 26 |
| xΜ | Sample mean | 5.2 |
| x β xΜ | Deviation from the mean | 4 β 5.2 = β1.2 |
| (x β xΜ)Β² | Squared deviation | 1.44 |
| Ξ£(x β xΜ)Β² | Sum of squared deviations | 14.8 |
| s | Sample standard deviation | β1.92 |
The squared step exists for a reason: deviations above the mean are positive and deviations below it are negative, so they sum to exactly zero every time. Squaring removes the signs so the distances don't cancel out. The cost is that you've now got squared units, which is why the final square root puts you back into the original scale.
One more symbol you'll meet: Ξ£(x β xΜ)Β² is sometimes called the sum of squares, and it's the single number most spreadsheet errors trace back to. If you only remember one intermediate value from this article, remember that one. It's the pivot the rest of the calculation swings on.
The Six Steps in the Order You Actually Perform Them
Follow this sequence exactly. Doing steps out of order β especially dividing before squaring β is the second most common error after the N versus N β 1 mix-up.
1: Count your values to get n. For the data set 4, 8, 6, 5, 3, n = 5. 2: Add every value to get Ξ£x. Here, 4 + 8 + 6 + 5 + 3 = 26. 3: Divide Ξ£x by n to get the mean. 26 Γ· 5 = 5.2. 4: Subtract the mean from each value to get the deviations: β1.2, 2.8, 0.8, β0.2, β2.2. 5: Square each deviation and add them: 1.44 + 7.84 + 0.64 + 0.04 + 4.84 = 14.8. 6: Divide by n β 1 (sample) or N (population), then take the square root.
For the sample: 14.8 Γ· 4 = 3.7, and the square root of 3.7 is about 1.9235. For the population: 14.8 Γ· 5 = 2.96, and the square root of 2.96 is about 1.7205.
The failure point to watch: if your deviations don't sum to zero (allow for rounding), you've made an arithmetic error somewhere in step 4. That's a free self-check. In our example, β1.2 + 2.8 + 0.8 + (β0.2) + (β2.2) = 0. If yours comes out to anything else, stop and re-add before squaring.
Why N β 1 Changes Your Answer and When to Use It
The N β 1 divisor is called Bessel's correction, and it exists because a sample's mean is itself estimated from the same data. The sample values cluster slightly closer to their own mean than they would to the true population mean, so dividing by the smaller n β 1 inflates the result just enough to compensate. Dividing by N on a sample systematically understates the real spread.
Here's the concrete difference on our data set: the sample standard deviation is 1.9235, and the population standard deviation is 1.7205. That's a gap of about 0.203, or roughly 12% β small here because n is 5, but on larger data the gap shrinks. With n = 100, the difference between dividing by 99 and 100 is only about 0.5%.
| Sample (n β 1) | Population (N) | |
|---|---|---|
| Divisor | 4 | 5 |
| Variance | 3.7 | 2.96 |
| Standard deviation | β1.9235 | β1.7205 |
| Use when | Data is a subset of a larger group | Data is the entire group |
Use the population formula only when you genuinely have every member of the group β every student in one class, every transaction in a closed ledger, every measurement in a finished experiment. Use the sample formula whenever the data stands in for something larger. In practice, most real-world work is sample work, and Excel's STDEV.S function assumes exactly that by default.
One-Pass Shortcut That Skips the Mean Subtraction
The standard method requires two passes over the data: one to find the mean, another to compute deviations. There's an algebraically identical shortcut that lets you compute the sum of squares in a single pass, which matters when you're working from a running tally or a long list you don't want to re-read.
The formula is: sum of squares = Ξ£xΒ² β (Ξ£x)Β² Γ· n. Square every value first, add those squares, then subtract the square of the total divided by n. For our data set: 16 + 64 + 36 + 25 + 9 = 150. And (26)Β² Γ· 5 = 676 Γ· 5 = 135.2. So 150 β 135.2 = 14.8 β exactly the number we got the long way.
From there it's identical: 14.8 Γ· 4 = 3.7, square root β1.9235. Same answer, one fewer pass.
The shortcut has one practical hazard: it involves subtracting two large numbers that may be close in value, which can cause floating-point rounding errors on computers when the values themselves are large. If you're calculating by hand or on a standard calculator, this is not a concern for typical data. If you're writing code with very large numbers, the two-pass method is generally safer numerically.
Reading the Result: What 1.92 Actually Tells You
A standard deviation of 1.9235 on a mean of 5.2 means a typical value sits roughly 1.9 units from the mean. Values between 3.28 and 7.12 (mean plus or minus one standard deviation) are unremarkable in this data set. That gives you a real feel for whether a new measurement is ordinary or unusual.
If your data is roughly bell-shaped, about 68% of values fall within one standard deviation of the mean, about 95% within two, and about 99.7% within three. That's the empirical rule, and it's a description of roughly normal data β not a law that applies to every distribution. Data that's heavily skewed, bimodal, or has extreme outliers will break it.
| Range around mean 5.2 | Values covered | Share of values in this data set |
|---|---|---|
| Β±1 SD (3.28β7.12) | 4, 5, 6 | 3 of 5 |
| Β±2 SD (1.36β9.04) | 3, 4, 5, 6, 8 | 5 of 5 |
With only five values, the percentages don't mean much β every value lands inside two standard deviations, which tells you the data is compact but says nothing about normality. That's the honest limitation of small samples, and it's worth saying out loud before anyone over-interprets a standard deviation from a handful of numbers.
Excel, Google Sheets, and the Function Names That Matter
If you're working in a spreadsheet, the arithmetic above is already automated β but you have to pick the right function. Excel and Google Sheets both use STDEV.S for sample data and STDEV.P for population data. In older Excel versions, STDEV and STDEVP are the equivalents, though Microsoft recommends the newer names.
For our data set entered in cells A1 through A5, =AVERAGE(A1:A5) returns 5.2 and =STDEV.S(A1:A5) returns about 1.9235. Swap to =STDEV.P(A1:A5) and you get about 1.7205. If you see a #DIV/0! error, you've selected a range with fewer than two numeric values β the sample function needs at least two.
| Task | Excel | Google Sheets |
|---|---|---|
| Mean | =AVERAGE(range) | =AVERAGE(range) |
| Sample SD | =STDEV.S(range) | =STDEV.S(range) |
| Population SD | =STDEV.P(range) | =STDEV.P(range) |
| Variance (sample) | =VAR.S(range) | =VAR.S(range) |
| Variance (population) | =VAR.P(range) | =VAR.P(range) |
The common failure: text and blank cells are ignored by these functions, but cells containing numbers stored as text (often visible via a small green triangle in Excel) are also ignored. If your mean looks wrong, check whether any values were entered as text.
Common Mistakes That Produce Wrong Numbers Every Time
Mistake 1: Dividing by N on a sample
This is the single most frequent error. It produces a standard deviation that's systematically too small. The fix is simple: ask yourself whether the data is the whole group or a stand-in for a larger group.
Mistake 2: Forgetting to take the square root
If your "standard deviation" has units squared, you divided and stopped too early. The square root is the last step, and it's not optional.
Mistake 3: Rounding the mean before computing deviations
If you round 5.2 to 5 before subtracting, every deviation is off by up to 0.2, and the squared errors compound. Keep full precision through the intermediate steps and round only the final answer.
Mistake 4: Mixing the mean and variance formulas
The mean uses n in the denominator. Standard deviation uses n β 1 (sample) or N (population) at the variance step. If you've divided your sum of squares by n, you've computed the mean of the squared deviations, not the sample variance.
Mistake 5: Including outliers without thinking
A single extreme value can inflate standard deviation dramatically. Before trusting the number, look at the raw data. Our data set has no outliers, but a value of 80 instead of 8 would push the sample standard deviation above 30, making it useless as a summary.
Worked Example With a Larger Data Set
The five-value example is easy to check, but real data sets are bigger. Here's a second worked case with twelve values: 12, 15, 11, 14, 16, 13, 12, 17, 15, 14, 13, 12. The mean is 14.0, since the total is 168 and 168 Γ· 12 = 14.
The deviations are β2, 1, β3, 0, 2, β1, β2, 3, 1, 0, β1, β2. Squaring them gives 4, 1, 9, 0, 4, 1, 4, 9, 1, 0, 1, 4 β total 38. For a sample, divide by 11: 38 Γ· 11 β 3.4545, and the square root is β1.8587. For a population, divide by 12: 38 Γ· 12 β 3.1667, and the square root is β1.7795.
| Sample | Population | |
|---|---|---|
| Mean | 14.0 | 14.0 |
| Sum of squared deviations | 38 | 38 |
| Divisor | 11 | 12 |
| Variance | β3.4545 | β3.1667 |
| Standard deviation | β1.8587 | β1.7795 |
Notice the pattern: as n grows, the sample and population answers converge. With n = 12 the gap is roughly 0.08, versus 0.203 on the five-value set. That's why practitioners stop worrying about the correction once samples are large β but for small samples, the choice genuinely affects your answer.
If you're wondering which mean and standard deviation to report when the audience is unclear, the honest move is to state your divisor explicitly in the write-up. "Mean 14.0, SD 1.86 (sample, n β 1)" leaves no room for confusion.
When the Mean and Standard Deviation Mislead You
Both numbers assume the data is roughly symmetric and doesn't have extreme outliers. When those assumptions fail, both statistics become misleading, and it's not a small effect. A single value can shift the mean by several units and inflate standard deviation by an order of magnitude.
Consider what happens if our five-value set gains one outlier: 4, 8, 6, 5, 3, 500. The mean jumps from 5.2 to about 87.67, and the sample standard deviation rises to roughly 201.4. That standard deviation tells you nothing useful about the other five values β they're all clustered within a few units of 5.
For skewed or outlier-heavy data, report the median and interquartile range instead, or report the mean and standard deviation alongside a statement that the data is skewed. If you want to keep a standard-deviation-style measure, look at robust alternatives. The important point: the arithmetic doesn't warn you. It just returns a number, and it's your job to decide whether that number describes the data.
FAQ
How do you calculate standard deviation by hand without a calculator?
Arithmetic alone, in the order given in the six-step sequence. The hardest part for most people is the square root at the end β if you don't have a square root key, you can long-divide an estimate. For 3.7, note that 1.9Β² = 3.61 and 2.0Β² = 4.0, so the answer sits closer to 1.92. Precision to two decimals is usually enough for a hand check.
Why does my standard deviation come out as zero?
Either every value in the data set is identical, or you've made a formula error. If the data set is {5, 5, 5, 5}, every deviation is zero and so is the standard deviation β the result is correct. In a spreadsheet, a zero commonly means the range you selected doesn't contain the values you think it does, so re-check the cell range before assuming a formula problem.
What does a standard deviation of 0.5 mean?
It means a typical value is half a unit from the mean, in the same units as the data. If you're measuring weights in kilograms with a mean of 70 and a standard deviation of 0.5, most values fall between 69.5 and 70.5. That's a very tight spread. The interpretation depends entirely on what the data is and what scale you're using.
Is standard deviation ever negative?
No. The square root of a non-negative number is non-negative, and the sum of squared deviations can't be negative. If you see a negative number presented as a standard deviation, either it's a variance reported with the wrong label or it's a transcription error. Variance itself is also always non-negative for the same reason.
How is standard deviation different from variance?
Variance is the average squared deviation from the mean, and standard deviation is the square root of variance. Variance is in squared units (kilogram-squared, dollar-squared), which makes it mathematically convenient but hard to interpret. Standard deviation is in the original units, which makes it easier to explain to someone who doesn't work with numbers daily.
Does standard deviation work the same way for groupby or aggregated data?
No β and this is where most real-world errors happen. If you're computing standard deviation from a summary table, you can't simply average the per-group standard deviations. You need the pooled formula using each group's count, mean, and sum of squares. If you have only the per-group means and standard deviations, the pooled result is computable, but only with the counts per group.
Why do the sample and population formulas give different answers on the same data?
Because they're estimating slightly different things. The population formula describes the spread of the data exactly as it sits. The sample formula estimates the spread of the larger group the sample was drawn from. The n β 1 divisor corrects for the fact that a sample's own mean is pulled toward its own values. The difference is largest for small samples and shrinks as n grows.
What if my data includes negatives?
Nothing changes. The deviations are still computed as value minus mean, and the squared values are still positive. For example, a data set of β2, 0, 2, 4 has a mean of 1, deviations of β3, β1, 1, 3, and a sum of squares of 20. The calculation is identical.