Introduction
Raw data is just a list of numbers. To understand it you summarise it (a typical value and a measure of spread) and picture it (histograms, box plots, scatter diagrams). This topic covers the mean, median and mode; range, interquartile range, variance and standard deviation; coding; estimating from grouped data; histograms with frequency density; outliers; and interpreting correlation and regression lines.
Why it matters
Two classes both average 60% on a test. In one, everyone scored between 55 and 65; in the other, scores ran from 10 to 100. The averages are the same but the stories are completely different. Measures of spread and good diagrams reveal what a single average hides.
Intuitive explanation
Standard deviation answers "how far, roughly, is a typical value from the mean?" Squaring the distances before averaging stops positive and negative deviations from cancelling, and the square root brings the units back.
In a histogram the area of each bar represents frequency. A wide class naturally contains more values, so we divide by the width: frequency density . The height then shows how crowded the data is in that range.
Formal definitions
For a frequency table, replace by , by , and by .
, (the median) and split the ordered data into quarters. Interquartile range: .
A common rule: a value more than below or above . Another: more than (or ) standard deviations from the mean. Use whichever the question gives.
Notation
- .
- is the standard deviation; some calculators show it as (not ).
- Regression line of on : .
Key formulae
If then and . Adding or subtracting a constant changes the mean but not the spread.
Median , where is the lower boundary of the median class, the cumulative frequency before it, its frequency and its width.
Key ideas
- Mean uses every value but is affected by outliers.
- Median is resistant to outliers; best for skewed data.
- Mode is the only average for categorical data.
A strong correlation between two variables does not show that one causes the other: both may depend on a third factor. Regression lines should only be used for interpolation, not extrapolation, and to predict from (not the other way round).
Why the variance formulae agree
Expand: . Divide by .
∎If , every deviation , so every squared deviation is divided by and the standard deviation by . The cancels in each deviation, which is why shifting does not change spread.
∎Let . Then , so . Squaring and averaging, , so . The shift cancels from every deviation, which is why it changes location but never spread.
∎(expand ; the cross term is ), which is smallest exactly when , and the minimum is . For the gradient is the number of values below minus the number above, so the minimum is at the median (Q53). The two measures of location are the answers to two different "closest point" problems.
∎For every real , . A quadratic in that is never negative has discriminant : , i.e. , with equality exactly when some makes every term zero, i.e. when the points are collinear (Q55).
∎Methods
Use class midpoints as values. The mean and standard deviation are then estimates.
Frequency density . If a scale is not given, use one known bar to find "frequency per unit area".
Compare a measure of location and a measure of spread, in context: "On average, Town A was warmer (higher median), and its temperatures were more consistent (smaller IQR)."
Examples
Data : , , , .
See the Worked examples tab for grouped data, histograms and coding.
Common mistakes
With unequal class widths, the vertical axis is frequency density.
has the same standard deviation as .
"The mean is higher" scores less than "The mean daily rainfall in Leuchars was higher".
Predictions outside the range of the data are unreliable.
Applications
- Quality control: a process is flagged if measurements drift more than 3 standard deviations from target.
- Medicine: growth charts show percentiles of children's heights.
- Weather and climate: comparisons in the large data set.
Connections
- Sampling: where data comes from.
- The normal distribution: mean and standard deviation as parameters.
- Hypothesis testing: testing correlation coefficients.
- Logarithms: changing variables to get straight-line models.
Summary
- ; .
- Median and IQR resist outliers; outliers beyond or .
- Coding : mean transforms fully, standard deviation divides by .
- Histogram: area frequency; height is frequency density.
- Correlation is not causation; interpolate, do not extrapolate.
Worked examples
Try each one yourself first, then open the solution.
Find the mean and standard deviation of the number of goals per match.
| Goals | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| Frequency | 4 | 7 | 5 | 3 | 1 |
Show the solution
- 1Totals
, , .
- 2Mean
.
- 3Standard deviation
, so .
,
Estimate the median time.
| Time (min) | ||||
|---|---|---|---|---|
| Frequency | 8 | 14 | 20 | 8 |
Show the solution
- 1Position
, so the median is the th value.
- 2Median class
Cumulative: . The 25th value is in .
- 3Interpolate
minutes.
minutes
Data are coded using . The coded data have and . Find and .
Show the solution
- 1Invert
.
- 2Mean
.
- 3Standard deviation
Adding 50 does not change spread: .
,
In a histogram, the bar for has height and represents items. Another bar for has height . How many items does it represent?
Show the solution
- 1Scale
First bar area units for 12 items: unit items.
- 2Second bar area
units.
- 3Frequency
items.
items
, . Are and outliers, using the rule?
Show the solution
- 1IQR
; .
- 2Fences
Lower ; upper .
- 3Decide
, not an outlier. , an outlier.
Only is an outlier
The regression line of fuel used (litres) on distance (km), for trips of 20 to 200 km, is . Interpret , estimate the fuel for 150 km, and comment on using it for 600 km.
Show the solution
- 1Gradient
Each extra km uses about litres of fuel.
- 2Estimate
litres. Reliable: 150 km is within the data range.
- 3600 km
Extrapolation far beyond 200 km: the estimate may be unreliable.
litres; 600 km is extrapolation
University-level ideas and the deeper mathematics behind this topic. Not needed for exams, but this is where the subject really opens up.
The geometry of least squares (university)
Put the deviations into vectors: and in . Then
where is the angle between the two vectors. So the correlation coefficient is the cosine of an angle, which is why it lies between and , and why it is unchanged by rescaling either variable (Q58): scaling a vector does not change its direction.
The least-squares line of on has gradient : is the orthogonal projection of onto the line spanned by . The residual vector is perpendicular to .
The sum of squared residuals is , the squared distance from to the point on the line. The closest point is the foot of the perpendicular, where , giving .
∎Pythagoras in now gives the analysis of variance for regression:
The line "explains" a fraction of the variation in , and the residuals carry the rest. With , the line explains % of the variation, not %.
With several explanatory variables , least squares projects onto the subspace they span. Writing the data as a matrix , the normal equations say exactly that the residual is perpendicular to every column of . This is the foundation of linear models, used everywhere from economics to machine learning.
In standardised units (, ) the regression line is simply . If , someone standard deviations above average on is predicted to be only standard deviations above average on . Galton (1886) noticed this with the heights of parents and children and called it "regression towards mediocrity", which is where the word regression comes from. It is a statistical effect, not a biological force: the line of on shows the same shrinkage in the other direction.
Robust statistics: resisting outliers (university)
The mean and standard deviation are efficient when data are well behaved, but one bad value can move them anywhere (Q49 turned into with a single point). Robust statistics quantifies and fixes this.
The breakdown point of a statistic is the smallest fraction of the data that, if replaced by arbitrary values, can make the statistic arbitrarily large.
- Mean: breakdown point , effectively : one value can drag it anywhere.
- Median: breakdown point : you must corrupt half the data to move it without limit. That is the best possible.
- IQR: breakdown point .
- Trimmed mean (drop the top and bottom % and average the rest): breakdown point .
Adding a value to others moves the mean by , which grows without limit in . The median moves by at most half the gap between neighbouring values, however large is. The influence function of a statistic records this effect as a function of : unbounded for the mean, bounded for the median.
The median absolute deviation is . For normal data , so is a robust estimate of the standard deviation. A common outlier rule flags values whose distance from the median exceeds ; unlike the rule, the outliers cannot hide themselves by inflating .
Why can the rule fail? Large outliers inflate , widening the fences until the outliers fall inside them. By Samuelson's inequality (Q52), with no value can ever be more than from the mean, so a "" rule could never flag anything. Rules built from the median and IQR or MAD do not suffer from this: the box plot's IQR rule, due to Tukey (1977), was designed with exactly this in mind.
The price of robustness is efficiency: for perfectly normal data the sample median needs about times as many observations as the mean for the same precision. Modern estimators (Huber's M-estimators) behave like the mean near the centre and like the median in the tails, getting most of both benefits.
When summaries mislead: Simpson, Anscombe and friends (university)
Summary statistics compress data, and compression loses information. Some losses are dramatic.
In 1973 Anscombe published four data sets of points each with (to two decimal places) the same means of and , the same variances, the same correlation and the same regression line . Plotted, they look nothing alike: one is a reasonable linear scatter, one a smooth curve, one a perfect line with one outlier, and one a vertical stack with a single far point creating all the correlation. The moral: always plot the data. (The "Datasaurus dozen" of 2017 takes this further, with identical summaries hiding a drawing of a dinosaur.)
It is possible for a relationship to hold within every group and reverse when the groups are combined.
In a well-known 1986 study, treatment A succeeded in of small stones (%) and of large stones (%); treatment B in of small (%) and of large (%). A is better for both sizes, yet overall A succeeded in % and B in %. The reason: A was used mostly on large stones, which are harder to treat. The combined rate is a weighted average , and A's weights are concentrated on the hard group.
The same mechanism appears in the variance decomposition (Q57) and in correlation: two groups each showing negative correlation can combine to show strong positive correlation if the group with larger also has larger overall. The combined is the sum of the within-group parts and a between-group part,
and the second term can dominate. Deciding whether to analyse the groups separately or together is not a statistical question but a causal one: which variable influences which?
Correlations between group averages (countries, schools, regions) are typically much stronger than, and can even have the opposite sign to, correlations between individuals. Averaging removes the within-group scatter, which is the denominator of . A strong correlation between national chocolate consumption and Nobel prizes (a real 2012 paper) says nothing about whether chocolate makes any individual cleverer.
Why does this work?
Variance is the mean squared distance from the mean. When estimating a population's variance from a sample, the sample mean is itself fitted to the data, which makes the squared distances slightly too small on average. Dividing by instead of (Bessel's correction) exactly removes this bias: .
Beyond the syllabus
Mathematical curiosities
A treatment can work better than another for men and for women, yet worse overall. In a famous kidney stone study, treatment A succeeded more often for both small and large stones, but B looked better overall because B was mostly used on the easier small stones. Aggregating data can reverse a trend when a lurking variable is unevenly distributed.
Four data sets with the same means, variances, correlation () and regression line, yet completely different scatter plots: a line, a curve, a line with one outlier, and a vertical cluster. Always draw the data.