Standard Deviation Calculator
Find the standard deviation of any list of numbers — population or sample. Enter your values below, and see the formula, a worked example, and ready-to-use Python code underneath.
Enter your data
Separate values with commas, spaces, or new lines — e.g. 12, 15, 9, 21, 14
Not sure which to pick? Sample is the more common choice — see the FAQ below.
Please enter at least one valid number.
What standard deviation tells you
Standard deviation measures how spread out a data set's values are around its mean. A small standard deviation means most values sit close to the mean; a large one means values are spread over a wider range. It's the most widely used measure of variability because it's expressed in the same units as the original data.
There are two versions of the formula. The population standard deviation is used when your data covers an entire group you care about. The sample standard deviation is used when your data is a subset drawn from a larger population — the far more common case in real analysis — and divides by n − 1 instead of n to correct for that.
Standard deviation formula
Sample: s = √( Σ(xᵢ − x̄)² / (n − 1) )
Python code
You can compute standard deviation manually, or with Python's statistics or NumPy:
# Method 1 — manual calculation (sample) data = [12, 15, 9, 21, 14] mean_value = sum(data) / len(data) squared_diffs = [(x - mean_value) ** 2 for x in data] sample_variance = sum(squared_diffs) / (len(data) - 1) sample_std = sample_variance ** 0.5 print(sample_std) # 4.4385 # Method 2 — statistics module import statistics statistics.pstdev(data) # population std statistics.stdev(data) # sample std # Method 3 — NumPy (ddof=1 for sample, ddof=0 for population) import numpy as np np.std(data, ddof=1) # sample std np.std(data, ddof=0) # population std
Worked example
Using the same five quiz scores as the mean calculator example — 12, 15, 9, 21, and 14 — which have a mean of 14.2.
| xᵢ | xᵢ − mean | (xᵢ − mean)² |
|---|---|---|
| 12 | −2.2 | 4.84 |
| 15 | 0.8 | 0.64 |
| 9 | −5.2 | 27.04 |
| 21 | 6.8 | 46.24 |
| 14 | −0.2 | 0.04 |
- 1Find the mean.
(12 + 15 + 9 + 21 + 14) / 5 = 14.2 - 2Subtract the mean from each value and square the result.
See the table above — the squared deviations sum to 78.8. - 3Divide by n (population) or n − 1 (sample).
Population: 78.8 / 5 = 15.76 | Sample: 78.8 / 4 = 19.7 - 4Take the square root.
Population: √15.76 = 3.9699 | Sample: √19.7 = 4.4385
If these five scores are the entire class, the population standard deviation is 3.97. If they're a sample from a larger class, the sample standard deviation is 4.44.
Frequently asked questions
Should I use population or sample standard deviation?
Use the population formula (divide by n) only when your data represents every member of the group you care about. Use the sample formula (divide by n − 1) when your data is a subset drawn from a larger population, which is the more common situation in practice, such as a survey sample or an experiment.
Why does the sample formula divide by n − 1 instead of n?
Dividing by n − 1, known as Bessel's correction, corrects for the fact that a sample's own mean is generally closer to the sample's values than the true population mean would be, which would otherwise make the sample variance a biased (too small) estimate of the population variance.
What is the difference between standard deviation and variance?
Variance is the average of the squared deviations from the mean. Standard deviation is the square root of the variance. Taking the square root brings the units back to the same scale as the original data, which is why standard deviation is usually easier to interpret than variance.
What does a standard deviation of zero mean?
A standard deviation of zero means every value in the data set is identical — there's no spread at all around the mean.
Can standard deviation be negative?
No. Standard deviation is a square root of an average of squared values, so it's always zero or positive.