Sample and Population
Two words appear in almost every statistical statement: population and sample.
- The population is the entire group you want to learn about: every voter in a country, every light bulb a factory produces this year, every tree in a forest.
- A sample is the part of the population you actually observe: the 1,200 voters you phoned, the 80 bulbs you tested, the 300 trees you measured.
Studying the whole population is called a census. It is often impossible (you can't test every bulb until it burns out, there would be none left to sell), too slow or too expensive. So we study a sample and generalise to the population. Inferential statistics is the art of doing that generalisation honestly.
The population depends on the question
The same data can be a sample or a population depending on what you ask:
| Data | Question | Population | Sample? |
|---|---|---|---|
| Heights of the 28 pupils in class 4B | "How tall is class 4B on average?" | class 4B | No, it is the whole population |
| Heights of the 28 pupils in class 4B | "How tall are 10-year-olds in the city?" | all 10-year-olds in the city | Yes (and probably not a very representative one) |
A sample must be representative
A sample is useful only if it represents the population: it should resemble the population in the ways that matter for the question. Random selection is the main tool for achieving that (see Sample Types).
Simulating a population
Because we can't usually see a whole population, let's invent one. Below is a population of 50,000 apple weights from an orchard. We know the true average because we created it, and we can check how well samples of different sizes estimate it:
import numpy as np
rng = np.random.default_rng(2024)
population = rng.normal(loc=182, scale=25, size=50_000) # weights in grams
print(f"population size: {population.size}")
print(f"population mean: {population.mean():.2f} g")
for n in [5, 30, 300, 3000]:
sample = rng.choice(population, size=n, replace=False)
print(f"sample of {n:4d}: mean = {sample.mean():7.2f} g")population size: 50000
population mean: 181.97 g
sample of 5: mean = 183.31 g
sample of 30: mean = 177.21 g
sample of 300: mean = 181.66 g
sample of 3000: mean = 181.95 g
Small samples can land a few grams away from the truth. Larger samples land closer. But no sample is guaranteed to hit the population mean exactly.
Sampling variability
If we draw many different samples of the same size, each gives a slightly different answer. This natural spread is called sampling variability. Let's draw 1,000 samples of size 30 and of size 300 and look at how much their means vary:
import numpy as np
rng = np.random.default_rng(2024)
population = rng.normal(loc=182, scale=25, size=50_000)
for n in [30, 300]:
means = [rng.choice(population, size=n, replace=False).mean() for _ in range(1000)]
means = np.array(means)
print(f"n={n:3d}: sample means range from {means.min():.1f} to {means.max():.1f}, "
f"spread (std) = {means.std():.2f} g")n= 30: sample means range from 168.2 to 196.6, spread (std) = 4.57 g
n=300: sample means range from 177.3 to 186.7, spread (std) = 1.46 g
Ten times more data made the sample means about three times less spread out (√10 ≈ 3.16). This square-root law shows up again in Estimation and the Central Limit Theorem.
Notation
Statisticians use different symbols for the population and the sample so you always know which one is meant:
| Quantity | Population | Sample |
|---|---|---|
| Size | N |
n |
| Mean | μ (mu) |
x̄ (x-bar) |
| Standard deviation | σ (sigma) |
s |
| Proportion | p |
p̂ (p-hat) |
The next lesson, Parameters and Statistics, explains this distinction.
Test yourself
A coffee chain wants to know the average spend of all its customers in 2025. It records 2,000 receipts. What is the population?
- The 2,000 receipts
- All customer purchases at the chain in 2025
- The chain's employees
- The average spend
Why do two random samples of the same size from the same population usually give different means?
- One of them was done incorrectly
- Sampling variability: each sample contains different individuals
- The population changed in between
- Means can't be computed for samples
Which symbol denotes a *sample* mean?
- μ
- σ
- x̄
- N