Population and sample statistics
Quick answer
A population is the set of units about which you want to make a statement. A sample is the subset or collection of draws you actually observe. A parameter describes a population or probability model; a statistic is computed from observed data. In ML, the distinction matters because a score on test records is not automatically the score on all future records.
Describe the population before calculating
A fictional packing line produces parcels with weights 2, 4, 4 and 10 kg in one small shift. If those four parcels are the entire population of interest, their mean is 5 kg. The median is 4 kg: sort the values and average the two middle ones when the count is even. The mean responds to extreme values more strongly than the median. For this finite population, variance is the average squared deviation from the mean, 9 kg². Standard deviation is its square root, 3 kg. These are descriptive quantities, not uncertainty intervals.
from statistics import mean, median, pvarianceweights = [2, 4, 4, 10]print(mean(weights), median(weights), pvariance(weights))Expected output (local Python 3.13.5):
5 4.0 9The mean is 5, the median is 4, and the population variance is 9.
Selection changes the target
If the scale records only the first three parcels, the observed mean is 10/3 kg. A convenient sample can systematically exclude heavy parcels. A random sample gives a defined selection mechanism; stratified sampling can preserve representation of shifts or machine types, with appropriate weights when selection probabilities differ. A larger convenience sample does not necessarily remove bias. Missing data may also depend on the unobserved outcome. Decide whether the target is this shift, future shifts or a particular machine before choosing a sampling plan.
population = [2, 4, 4, 10]observed = population[:3]print(round(sum(observed)/len(observed), 3))print(sum(population)/len(population))Expected output (local Python 3.13.5):
3.3335.0The selected sample underrepresents the heaviest parcel; this is a designed illustration of selection, not a proof that all small samples are biased.
Common mistakes
Do not use a row count as the number of independent units when the same parcel is measured repeatedly. Do not call a sample mean the population mean without evidence. The mean is undefined for an empty dataset; returning zero silently would fabricate a measurement. Variance is in squared units; standard deviation is in the original units.
Practice and next steps
For [3, 3, 6, 12], compute the mean and median; then remove the largest item and explain what population claim is no longer justified. Next, examine how estimates vary across repeated samples.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Population and sample statistics — knowledge check
Apply statistical reasoning to original synthetic examples.
Which is a parameter when studying all parcels produced in one shift?
What is the median of [1, 4, 6, 20]?
What are the units of variance for weights measured in kg?
A scale records only light parcels. What is the main concern?
A dataset contains ten measurements of each parcel. Which is safest?