Range, Variance, and Standard Deviation: Measuring the Chaos

In the last lesson, we learned how to find the exact center of our data using the Mean, Median, and Mode. But knowing the centre only tells you half the story.

Imagine you are choosing a city to move to, and you hate extreme weather. You look at two cities:

  • City A: Has an average daily temperature of 30°C.
  • City B: Has an average daily temperature of 30°C.

Based purely on the Mean, they look identical. But what if City A is 30°C every single day of the year, while City B is 45°C in the summer and 5°C in the winter?

If you only look at the average, City B will completely blindside you. To get the full picture, you have to measure the spread (also known as dispersion). You need to know how tightly the data hugs the center, or how wildly it swings away from it.

To measure this chaos, we use three tools: Range, Variance, and Standard Deviation.

1. The Range (The Simplest Measure)

The Range is the most basic measure of spread. It tells you the total distance between your absolute lowest number and your absolute highest number.

To calculate it, simply subtract the minimum value from the maximum value.

  • The Advantage: It is incredibly fast and easy to understand.
  • The Fatal Flaw: It is completely hijacked by outliers. If you measure the wealth of 100 people in a room, and Elon Musk walks in, your Range expands by 200 billion dollars. Furthermore, the Range completely ignores every single data point that sits between the highest and lowest numbers, blinding you to what is actually happening in the middle.

2. Variance (The Mathematical Stepping Stone)

To get a true measure of the spread, we need a calculation that actually includes every single data point. We want to know: On average, how far away is each data point from the Mean?

This is what Variance attempts to solve.

Here is how the math works in plain English:

  1. Find the Mean of your dataset.
  2. Take every individual number and subtract the Mean to see how far away it is (the deviation).
  3. Square that difference. (We do this because if we didn’t, the positive distances and negative distances would just cancel each other out to zero. Squaring them turns everything positive and severely punishes extreme outliers).
  4. Add all those squared numbers up, and divide by the number of items you have.

Here is the formal formula for a Sample Variance ($s^2$):

$$s^2 = \frac{\sum (x_i – \bar{x})^2}{n – 1}$$

Note on the “n – 1”: When we test a small sample instead of an entire population, we divide by $n – 1$ instead of just $n$. This is a mathematical trick (called Bessel’s Correction) that makes our estimate a little bit larger and more conservative to account for the unknown.

  • The Fatal Flaw of Variance: Because we squared all the numbers in Step 3, our final answer is in squared units. If you are measuring temperature, your variance is in “squared degrees.” If you are measuring money, your variance is in “squared Rupees.” This makes Variance an absolute nightmare for human beings to actually interpret.
  • To know more about why variance is squared, read this.

3. Standard Deviation (The Gold Standard)

Because Variance gives us a bizarre, squared number, we have to fix it. How do you undo a square? You take the square root.

The Standard Deviation is simply the square root of the Variance.

$$s = \sqrt{\frac{\sum (x_i – \bar{x})^2}{n – 1}}$$

By taking the square root, we bring the math back into the original units. If your data is in dollars, your Standard Deviation is in dollars.

Standard Deviation is the ultimate measure of spread. It tells you exactly how much the data typically deviates from the average.

  • A low Standard Deviation means your data is highly consistent and clustered tightly around the Mean (like City A’s weather).
  • A high Standard Deviation means your data is highly chaotic and spread out (like City B’s weather).

How to Calculate Spread in Excel, Python, and R

Because the formulas for Variance and Standard Deviation are tedious to do by hand, statisticians always rely on software.

Important Note: All software will ask if you are calculating a Sample (a small piece of the data) or a Population (every piece of data in existence). In 99% of real-world scenarios, you are working with a Sample.

Microsoft Excel

Assuming your data is in cells A1 through A10:

  • Range: Type =MAX(A1:A10) - MIN(A1:A10)
  • Variance (Sample): Type =VAR.S(A1:A10)
  • Standard Deviation (Sample): Type =STDEV.S(A1:A10)
Python

Python’s built-in statistics module makes this incredibly straightforward.

import statistics

data = [70, 72, 71, 75, 68, 70, 73]

# Calculate Range
range_val = max(data) - min(data)
print(range_val) # Output: 7

# Calculate Variance and Standard Deviation (Defaults to Sample)
print(statistics.variance(data)) # Output: 5.238
print(statistics.stdev(data))    # Output: 2.288
R

R was built for this. It handles sample variance and standard deviation natively with tiny, two-letter commands.

data <- c(70, 72, 71, 75, 68, 70, 73)

# Calculate Range
max(data) - min(data) # Output: 7

# Calculate Variance and Standard Deviation (Defaults to Sample)
var(data) # Output: 5.238095
sd(data)  # Output: 2.288689

Now that you know how to measure the center and the spread, you have the main tools of Descriptive Statistics. But there is another way to look at data: slicing it into chunks. In the next lesson, we will look at how to chop data up using Quartiles and Percentiles.

🗺️ Part of Path 2: Descriptive Statistics

You are reading step 2 of our module on summarising data. Continue your journey below or view the full syllabus.

← Previous Lesson
Mean, Median, and Mode
Next Lesson →
Quartiles and Percentiles