Concept units

Summarizing a list of numbers

Basic

Before you start

You need nothing else first. This unit starts from scratch.

The idea in one paragraph

Two numbers summarize a long list well. The mean, or average, says where the values sit: add them up and divide by how many there are. The standard deviation says how spread out they are: roughly, how far a typical value lies from the mean. Two lists can share a mean and still differ a lot in spread. Together the two numbers give the center and the width of the data.

The mean is the balance point

Five friends rate a film from 0 to 10: 4, 8, 6, 5 and 7. The mean is the sum divided by the count: 30 / 5 = 6. If the ratings were weights on a ruler, the ruler would balance at 6. Each value's deviation is its distance from the mean, with a sign: here −2, +2, 0, −1 and +1. The deviations always add to zero, which is what "balance point" means.

The standard deviation is a typical distance from the mean

Five other friends rate the same film 2, 10, 6, 3 and 9. Their mean is also 30 / 5 = 6, but they disagree far more. To measure that, average the squared deviations, then take the square root. Squaring makes every deviation positive and counts large ones more. The average of the squares is the variance. Its square root, the standard deviation, is back in the same units as the data (rating points, here).

σ = √( average of (value − mean)2 )

The Greek letter σ (sigma) is the usual symbol for the standard deviation, and μ (mu) for the mean.

Worked example
RatingsDeviations from 6SquaresMean of squaresσ
Group 14, 8, 6, 5, 7−2, 2, 0, −1, 14, 4, 0, 1, 110 / 5 = 2√2 ≈ 1.41
Group 22, 10, 6, 3, 9−4, 4, 0, −3, 316, 16, 0, 9, 950 / 5 = 10√10 ≈ 3.16

Same mean, 6. Group 2's standard deviation is more than twice group 1's, which matches how much more they disagree.

Your turn. Find the mean and standard deviation of 1, 3, 5, 7.

Answer

The mean is 16 / 4 = 4. The deviations are −3, −1, 1, 3, with squares 9, 1, 1, 9. Their mean is 20 / 4 = 5, so σ = √5 ≈ 2.24.

The mean marks the center; the band marks one standard deviation each side
mean
Values
mean =   standard deviation =
Try this. Drag the dots left and right. Goal 1: keep the mean at 6 but make the standard deviation 0. Goal 2: keep the mean at 6 and make the standard deviation as large as you can. Predict the answer to each before you drag.
This is a simplification

This page divides by the number of values, n. When a list is a sample from a larger group and you want to estimate the larger group's spread, statisticians divide by n − 1 instead, which gives a slightly larger number. NumPy's np.std divides by n unless you pass ddof=1. Also, one extreme value can drag the mean a long way; the median, the middle value once the list is sorted, is less sensitive to it.

mean.py: the two summaries in NumPy

import numpy as np

a = np.array([4, 8, 6, 5, 7])
b = np.array([2, 10, 6, 3, 9])
print(a.mean(), b.mean())                    # same middle
print(round(a.std(), 3), round(b.std(), 3))  # different spread
6.0 6.0
1.414 3.162

Check yourself

  1. What is the mean of 2, 4 and 9?

    Answer

    15 / 3 = 5.

  2. You add 10 to every value in a list. What happens to the mean and to the standard deviation? What if you multiply every value by 3 instead?

    Answer

    Adding 10 raises the mean by 10 and leaves the standard deviation alone, because every deviation stays the same. Multiplying by 3 triples both the mean and the standard deviation.

  3. When is a list's standard deviation exactly zero?

    Answer

    When every value is the same. Then every deviation is zero.

Go further

Optional background, for readers who want more than this page.

Where this shows up

Units that build on this one