Spread of Data
Dispersion measures explained: what the average deliberately conceals.
You know the average — but the average alone does not reveal how far the data actually spreads. Two data sets with the same mean can look completely different: one tightly clustered, the other wildly scattered.
Spread measures capture this hidden dimension. This article walks you through three tools: range (quick but crude), variance (precise but in squared units), and standard deviation (the gold standard that speaks the same language as your data).
Range — The Quick-and-Dirty Spread Measure
Definition
Range
Analogy
Example
Definition
Example: Two Classes, Same Average
Class A: [40, 42, 45, 48, 50, 52, 55, 58, 60] — range 20, mean ~50. Class B: [10, 45, 48, 49, 50, 51, 52, 55, 90] — range 80, mean ~50. Class B looks four times more spread, but most students score nearly identically to A — only two outliers (10 and 90) inflate the range.
Class A vs. Class B
Caution
Misconception: Same Mean = Same Spread
Mean and spread are independent properties. [0, 0, 0, 100] and [24, 25, 25, 26] both have a mean of 25 but wildly different spreads. Only spread measures reveal the difference.
Variance — Average Squared Distance
Definition
Variance
Analogy
Example
Definition
Variance in 4 Steps
- 1. Compute the meanadd all values, divide by count
- 2. Compute deviationseach value minus the mean
- 3. Square each deviationnegatives become positive, large ones get amplified
- 4. Average the squaresdivide by n for population, by n-1 for sample
Worked Example
Data: [2, 4, 4, 4, 5, 5, 7, 9] Mean = 40/8 = 5
Deviations: -3, -1, -1, -1, 0, 0, +2, +4 (Sum = 0)
Squared: 9, 1, 1, 1, 0, 0, 4, 16 (Sum = 32)
Population variance: 32/8 = 4
Sample variance: 32/7 = 4.57Python: statistics Module
import statistics
data = [2, 4, 4, 4, 5, 5, 7, 9]
statistics.pvariance(data) # → 4 (population)
statistics.variance(data) # → 4.571 (sample, n-1)Caution
Misconception: Always Divide by n
For a complete population: yes. For a sample drawn from a larger population: divide by n-1 (Bessel's correction). The sample mean is computed from the data itself, making deviations artificially small — n-1 compensates for this lost degree of freedom.
Why n-1 instead of n? When you compute the mean from your sample and then measure deviations from that mean, the deviations are systematically too small. The reason: the sample mean sits centrally in the sample by definition and minimises the squared distances — it underestimates the true population spread. Dividing by n-1 (instead of n) corrects this bias. The number n-1 is called "degrees of freedom": once the mean of n values is fixed, only n-1 values can be chosen freely; the last one follows.
Standard Deviation — Variance in Human Units
Definition
Standard Deviation
Analogy
Example
Definition
Calculation from the Variance Example
Variance = 4, so standard deviation = sqrt(4) = 2. Data [2, 4, 4, 4, 5, 5, 7, 9] with mean 5. The interval [5-2, 5+2] = [3, 7] contains 6 of 8 values (75%) — close to the expected 68% for normally distributed data.
The 68-95-99.7 Rule
Example: Temperature Comparison
Mean 20 °C, standard deviation 2 °C → 68% of days between 18 °C and 22 °C. Same mean with standard deviation 8 °C → 68% between 12 °C and 28 °C — a fundamentally different climate.
Caution
Misconception: Variance and Standard Deviation Are the Same
Variance is in squared units; standard deviation is in original units. They measure the same concept (spread) on different scales. Reports and interpretations almost always use standard deviation because it is directly comparable to the data.
In machine learning pipelines, features are often z-normalised: z = (x - mean) / standard deviation. The result has mean 0 and standard deviation 1. Why? Algorithms like k-Nearest Neighbors or Gradient Descent treat all features equally — without normalisation, features with large numeric values dominate.
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
# Each feature now has mean 0, std 1Range vs. Standard Deviation
Maximum minus minimum. Instant to compute. Shows only the extremes. A single outlier can distort everything. Good as a first overview.
Square root of average squared deviation. In original units. Considers all data points. The standard in statistics and ML.
Interactive: Compute Variance & Standard Deviation
You have learned about range, variance, and standard deviation. Enter your own data points and watch live how the spread measures change. Compare the tight dataset with the wide one — and see how a single outlier makes the variance explode.
n is the number of values. “÷ n” is the population variance (like statistics.pvariance): use it when your numbers are the whole group. “÷ n-1” is the sample variance with Bessel's correction (like statistics.variance): use it when your numbers are only a sample from a larger group. The standard deviation shown here is the square root of the variance ÷ n.
Note
Key Takeaways
- Range (max - min) is quick but misleading — a single outlier can inflate it while 99% of data stays clustered.
- Variance averages the squared deviations from the mean — squaring ensures large deviations count more and prevents positive/negative cancellation.
- Standard deviation = sqrt(variance), restoring the original unit — combine it with the mean to say: most values lie within 1 standard deviation (68% for normal distributions).
Check
Quiz: Measures of Spread
Why is the range misleading when outliers are present?
Select one answer
1. Why is the range misleading when outliers are present?
2. Temperature data: mean 20 °C, standard deviation 3 °C. Within which range do approximately 68% of values fall (assuming normal distribution)?
3. You compute the variance of a data set: 16. What is the standard deviation?
4. Two manufacturing lines produce screws. Line A: mean 50 mm, standard deviation 0.1 mm. Line B: mean 50 mm, standard deviation 2 mm. Which line likely produces more defective screws?
Check
Learning Goals
Can you explain this in your own words? Tick what you've got.
0 of 3 done