You check the same three numbers in two places. One answer is about 1.63. The other is 2. Before blaming floating-point arithmetic, check the denominator.
A small example you can run
import statistics
values = [2, 4, 6]
print(statistics.pstdev(values)) # 1.632993161855452
print(statistics.stdev(values)) # 2.0
For a descriptive standard deviation of this complete list, the population convention divides by n. To estimate population variance from an independent identically distributed sample, the usual sample variance divides by n−1; taking its square root gives the sample standard deviation, which is not itself generally unbiased. Python names the choice explicitly: pstdev versus stdev. Which convention does your assignment or application need?
Fictional student scene: Two flatmates, Leo and Sam, both average five hours of study a day across a six-day stretch. Leo sits at his desk for exactly five hours every single afternoon, maintaining a steady, predictable rhythm. Sam alternates between two 15-hour marathon sessions fueled by panic and four days of staring meaningfully at a closed textbook while questioning his life choices. Their arithmetic averages agree completely. Their lived reality, concentration levels, and academic stamina do not.
The core idea: why averages alone hide the story
A statistical average—specifically the arithmetic mean—tells you where the center of gravity lies, but it tells you nothing about how chaotic or uniform the surrounding terrain is. Standard deviation is the standard mathematical tool designed to measure dispersion or spread around that mean. A larger standard deviation means that individual data points are scattered more widely from the center. A larger standard deviation means more variation. Whether that is a problem depends on what you are measuring.
Let a collection of numerical observations be represented by x_1, x_2, …, x_n, where n is the total count of observations. The population arithmetic mean is denoted by μ (mu), calculated by summing all values and dividing by n: μ = (x₁ + x₂ + … + xₙ) / n
When you measure how far each observation sits from the center, you look at the raw deviation, x_i - μ. If you simply add up these raw deviations without modifying them, the positive deviations (values above the mean) and negative deviations (values below the mean) will always cancel each other out, summing precisely to zero. To prevent this cancellation, we square each deviation: (x_i - μ)^2. Squaring ensures every term is non-negative and heavily penalizes values that sit far away from the center. Averaging these squared deviations gives us the population variance, σ^2 (sigma squared): σ² = [(x₁ − μ)² + (x₂ − μ)² + … + (xₙ − μ)²] / n
Because squaring changes our units (for instance, turning hours of study into squared hours), we take the non-negative square root of the variance to return the metric to the original units of measurement. This gives us the population standard deviation, σ:
σ = sqrt(variance)
Step-by-step worked example: population versus sample
Let us work through a concrete numerical dataset. Treat the values 2, 4, 4, and 6 as an entire closed population (n = 4).
- Step 1: Find the mean. Sum the observations (2 + 4 + 4 + 6 = 16) and divide by n = 4, giving a mean μ= 4.
- Step 2: Calculate deviations from the mean. Subtract 4 from each value: 2 - 4 = -2, 4 - 4 = 0, 4 - 4 = 0, and 6 - 4 = 2.
- Step 3: Square each deviation. (-2)^2 = 4, 0^2 = 0, 0^2 = 0, and 2^2 = 4.
- Step 4: Average the squared deviations. Sum the squares (4 + 0 + 0 + 4 = 8) and divide by n = 4. This gives the population variance: 8/4 = 2.
- Step 5: Take the square root. The population standard deviation is σ= √(2) ≈1.414.
What if these exact same four values—2, 4, 4, and 6—are not a closed population, but rather a random sample drawn to estimate the spread of a broader group? In inferential statistics, dividing the squared deviations from the sample mean by n is biased downward, on average, as an estimator of population variance because our sample mean is already pulled toward the sample points. To correct this, we use Bessel's correction, dividing by n - 1 instead of n. For our sample (n = 4, so n - 1 = 3):
- The sum of squared deviations remains 8.
- The sample variance becomes s^2 = 8/3 ≈2.667.
- The sample standard deviation is s = √(8/3) ≈1.633.
A second worked example: evaluating a stable study week
Consider a second fictional dataset of study-hour observations: 3, 5, 5, and 7.
- Mean: μ = (3 + 5 + 5 + 7)/4 = 20/4 = 5.
- Deviations: 3 - 5 = -2, 5 - 5 = 0, 5 - 5 = 0, 7 - 5 = 2. Notice that these deviations are identical in magnitude to our first example, even though the center shifted from 4 to 5.
- Squared deviations: 4, 0, 0, 4.
- Population variance: 8/4 = 2, and population standard deviation σ= √(2) ≈1.414.
This demonstrates a fundamental property of standard deviation: shifting every data point up or down by adding a constant value moves the mean but leaves the spread—and therefore the standard deviation—completely untouched.
Three common mistakes to avoid
- Mistake 1: Choosing the denominator by habit rather than context. Always check whether your dataset represents an entire defined population (divide by n) or a sample intended to estimate a wider population (divide by n - 1). Blindly applying one formula everywhere introduces systematic bias.
- Mistake 2: Assuming the n - 1 correction makes sample standard deviation unbiased. While dividing by n - 1 makes the sample variance an unbiased estimator of population variance, taking the square root generally leaves the sample standard deviation biased. These estimator statements assume independent identically distributed observations with finite variance.
- Mistake 3: Automatically deleting outliers. Standard deviation squares deviations, making it sensitive to extreme values. A single unusually large data point deserves careful investigation to check for recording errors, but it should never be discarded purely because it inflates the spread.
Try it yourself, then check
- Exercise 1: For the dataset 5, 5, 5, 5, what is the population standard deviation? Answer: 0. Because every observation equals the mean (5), every deviation is 0. The squared sum is 0, making both variance and standard deviation 0. There is zero dispersion.
- Exercise 2: If every observation in a dataset is multiplied by 3, how does the population standard deviation change? Answer: It is multiplied by 3. Scaling every data point stretches the entire distribution outward by a factor of 3, scaling all distances (and thus the standard deviation) proportionally. (Variance, being squared, would increase by a factor of 3^2 = 9).
- Exercise 3: You calculate a sample variance of 16 for a dataset of size n = 9. What is the sample standard deviation? Answer: 4. The sample standard deviation is simply the square root of the sample variance (√(16) = 4). The sample size n = 9 was extra background information not needed to take that square root.
Further study: the linked open learning reference. The examples above are original teaching examples.
We are building Matheria for calculation, organized study, and learning resources. Explore Matheria. Which step should we explain in a follow-up? Leave a specific question.
Editorial note: Prepared with AI assistance and discussed with Gemini before publication. Student scenes and datasets are fictional unless stated otherwise. The cover is AI-generated conceptual artwork, not experimental evidence.
Python reference: https://docs.python.org/3/library/statistics.html
This is a Matheria Study adaptation of our math series, prepared with AI/Gemini assistance and independently checked. The code above was run locally.
Top comments (0)