Lemma
← All topics
Statistics

Data presentation and interpretation

Summaries, diagrams and what they really tell you.

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

IntuitionStandard deviation is a typical distance from the mean

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.

IntuitionHistograms show density, not height

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 =frequencyclass width= \frac{\text{frequency}}{\text{class width}}. The height then shows how crowded the data is in that range.

Formal definitions

DefinitionMean, variance and standard deviation
xˉ=∑xn,σ2=∑x2n−xˉ2=Sxxn,σ=σ2\bar x = \frac{\sum x}{n}, \qquad \sigma^2 = \frac{\sum x^2}{n} - \bar x^2 = \frac{S_{xx}}{n}, \qquad \sigma = \sqrt{\sigma^2}

For a frequency table, replace ∑x\sum x by ∑fx\sum fx, ∑x2\sum x^2 by ∑fx2\sum fx^2, and nn by ∑f\sum f.

DefinitionQuartiles and IQR

Q1Q_1, Q2Q_2 (the median) and Q3Q_3 split the ordered data into quarters. Interquartile range: IQR=Q3−Q1\text{IQR} = Q_3 - Q_1.

DefinitionOutlier

A common rule: a value more than 1.5×IQR1.5 \times \text{IQR} below Q1Q_1 or above Q3Q_3. Another: more than 22 (or 33) standard deviations from the mean. Use whichever the question gives.

Notation

  • Sxx=∑(x−xˉ)2=∑x2−(∑x)2nS_{xx} = \sum(x - \bar x)^2 = \sum x^2 - \frac{(\sum x)^2}{n}.
  • σ\sigma is the standard deviation; some calculators show it as σx\sigma_x (not sxs_x).
  • Regression line of yy on xx: y=a+bxy = a + bx.

Key formulae

IdentitiesCoding

If y=x−aby = \dfrac{x - a}{b} then yˉ=xˉ−ab\bar y = \dfrac{\bar x - a}{b} and σy=σx∣b∣\sigma_y = \dfrac{\sigma_x}{|b|}. Adding or subtracting a constant changes the mean but not the spread.

IdentitiesInterpolation for grouped data

Median ≈L+n2−Ff×w\approx L + \dfrac{\frac n2 - F}{f}\times w, where LL is the lower boundary of the median class, FF the cumulative frequency before it, ff its frequency and ww its width.

Key ideas

PropositionWhich average?
  • 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.
PropositionCorrelation is not causation

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 yy from xx (not the other way round).

Why the variance formulae agree

Proof1n∑(x−xˉ)2=1n∑x2−xˉ2\frac1n\sum(x - \bar x)^2 = \frac1n\sum x^2 - \bar x^2

Expand: ∑(x−xˉ)2=∑x2−2xˉ∑x+nxˉ2=∑x2−2nxˉ2+nxˉ2=∑x2−nxˉ2\sum(x - \bar x)^2 = \sum x^2 - 2\bar x\sum x + n\bar x^2 = \sum x^2 - 2n\bar x^2 + n\bar x^2 = \sum x^2 - n\bar x^2. Divide by nn.

∎
ProofCoding

If y=x−aby = \frac{x - a}{b}, every deviation y−yˉ=x−xˉby - \bar y = \frac{x - \bar x}{b}, so every squared deviation is divided by b2b^2 and the standard deviation by ∣b∣|b|. The aa cancels in each deviation, which is why shifting does not change spread.

∎
ProofWhat coding does to the mean and standard deviation

Let yi=xi−aby_i = \frac{x_i - a}{b}. Then yˉ=1n∑xi−ab=xˉ−ab\bar y = \frac1n\sum\frac{x_i - a}{b} = \frac{\bar x - a}{b}, so yi−yˉ=xi−xˉby_i - \bar y = \frac{x_i - \bar x}{b}. Squaring and averaging, σy2=σx2b2\sigma_y^2 = \frac{\sigma_x^2}{b^2}, so σy=σx∣b∣\sigma_y = \frac{\sigma_x}{|b|}. The shift aa cancels from every deviation, which is why it changes location but never spread.

∎
ProofThe mean minimises squared deviations, the median absolute ones

∑(xi−a)2=∑(xi−xˉ)2+n(xˉ−a)2\sum(x_i - a)^2 = \sum(x_i - \bar x)^2 + n(\bar x - a)^2 (expand (xi−xˉ)+(xˉ−a)(x_i - \bar x) + (\bar x - a); the cross term is 00), which is smallest exactly when a=xˉa = \bar x, and the minimum is nσ2n\sigma^2. For ∑∣xi−a∣\sum|x_i - a| the gradient is the number of values below aa 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.

∎
ProofThe correlation coefficient lies between −1-1 and 11

For every real tt, ∑((yi−yˉ)−t(xi−xˉ))2=Syy−2tSxy+t2Sxx≥0\sum\big((y_i - \bar y) - t(x_i - \bar x)\big)^2 = S_{yy} - 2tS_{xy} + t^2S_{xx} \ge 0. A quadratic in tt that is never negative has discriminant ≤0\le 0: Sxy2≤SxxSyyS_{xy}^2 \le S_{xx}S_{yy}, i.e. ∣r∣≤1|r| \le 1, with equality exactly when some tt makes every term zero, i.e. when the points are collinear (Q55).

∎

Methods

MethodGrouped data

Use class midpoints as xx values. The mean and standard deviation are then estimates.

MethodHistogram

Frequency density =frequencyclass width= \frac{\text{frequency}}{\text{class width}}. If a scale is not given, use one known bar to find "frequency per unit area".

MethodComparing distributions

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

ExampleMean and standard deviation

Data 2,4,4,4,5,5,7,92, 4, 4, 4, 5, 5, 7, 9: xˉ=5\bar x = 5, ∑x2=232\sum x^2 = 232, σ2=2328−25=4\sigma^2 = \frac{232}8 - 25 = 4, σ=2\sigma = 2.

See the Worked examples tab for grouped data, histograms and coding.

Common mistakes

Common mistakePlotting frequency in a histogram

With unequal class widths, the vertical axis is frequency density.

Common mistakeCoding the spread with the shift

y=x−100y = x - 100 has the same standard deviation as xx.

Common mistakeComparing without context

"The mean is higher" scores less than "The mean daily rainfall in Leuchars was higher".

Common mistakeExtrapolating a regression line

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

Summary

  • xˉ=∑xn\bar x = \frac{\sum x}n; σ2=∑x2n−xˉ2\sigma^2 = \frac{\sum x^2}{n} - \bar x^2.
  • Median and IQR resist outliers; outliers beyond Q1−1.5 IQRQ_1 - 1.5\,\text{IQR} or Q3+1.5 IQRQ_3 + 1.5\,\text{IQR}.
  • Coding y=x−aby = \frac{x - a}{b}: mean transforms fully, standard deviation divides by ∣b∣|b|.
  • Histogram: area ∝\propto frequency; height is frequency density.
  • Correlation is not causation; interpolate, do not extrapolate.

Worked examples

Try each one yourself first, then open the solution.

Example 1Mean and standard deviation from a table

Find the mean and standard deviation of the number of goals per match.

Goals xx01234
Frequency ff47531
Show the solution
  1. 1Totals

    ∑f=20\sum f = 20, ∑fx=0+7+10+9+4=30\sum fx = 0 + 7 + 10 + 9 + 4 = 30, ∑fx2=0+7+20+27+16=70\sum fx^2 = 0 + 7 + 20 + 27 + 16 = 70.

  2. 2Mean

    xˉ=3020=1.5\bar x = \frac{30}{20} = 1.5.

  3. 3Standard deviation

    σ2=7020−1.52=3.5−2.25=1.25\sigma^2 = \frac{70}{20} - 1.5^2 = 3.5 - 2.25 = 1.25, so σ=1.118\sigma = 1.118.

Answer

xˉ=1.5\bar x = 1.5, σ=1.12\sigma = 1.12

Example 2Median by interpolation

Estimate the median time.

Time tt (min)0≤t<100 \le t < 1010≤t<2010 \le t < 2020≤t<4020 \le t < 4040≤t<6040 \le t < 60
Frequency814208
Show the solution
  1. 1Position

    n=50n = 50, so the median is the 2525th value.

  2. 2Median class

    Cumulative: 8,22,42,508, 22, 42, 50. The 25th value is in 20≤t<4020 \le t < 40.

  3. 3Interpolate

    20+25−2220×20=2320 + \dfrac{25 - 22}{20}\times20 = 23 minutes.

Answer

2323 minutes

Example 3Undoing a coding

Data are coded using y=x−505y = \dfrac{x - 50}{5}. The coded data have yˉ=2.4\bar y = 2.4 and σy=1.6\sigma_y = 1.6. Find xˉ\bar x and σx\sigma_x.

Show the solution
  1. 1Invert

    x=5y+50x = 5y + 50.

  2. 2Mean

    xˉ=5(2.4)+50=62\bar x = 5(2.4) + 50 = 62.

  3. 3Standard deviation

    Adding 50 does not change spread: σx=5×1.6=8\sigma_x = 5 \times 1.6 = 8.

Answer

xˉ=62\bar x = 62, σx=8\sigma_x = 8

Example 4Reading a histogram

In a histogram, the bar for 10≤x<1510 \le x < 15 has height 44 and represents 1212 items. Another bar for 15≤x<2515 \le x < 25 has height 1.51.5. How many items does it represent?

Show the solution
  1. 1Scale

    First bar area =5×4=20= 5 \times 4 = 20 units for 12 items: 11 unit =0.6= 0.6 items.

  2. 2Second bar area

    10×1.5=1510 \times 1.5 = 15 units.

  3. 3Frequency

    15×0.6=915 \times 0.6 = 9 items.

Answer

99 items

Example 5Checking for outliers

Q1=18Q_1 = 18, Q3=30Q_3 = 30. Are 33 and 4949 outliers, using the 1.5×IQR1.5 \times \text{IQR} rule?

Show the solution
  1. 1IQR

    30−18=1230 - 18 = 12; 1.5×12=181.5 \times 12 = 18.

  2. 2Fences

    Lower 18−18=018 - 18 = 0; upper 30+18=4830 + 18 = 48.

  3. 3Decide

    3>03 > 0, not an outlier. 49>4849 > 48, an outlier.

Answer

Only 4949 is an outlier

Example 6Using a regression line

The regression line of fuel used yy (litres) on distance xx (km), for trips of 20 to 200 km, is y=1.2+0.065xy = 1.2 + 0.065x. Interpret 0.0650.065, estimate the fuel for 150 km, and comment on using it for 600 km.

Show the solution
  1. 1Gradient

    Each extra km uses about 0.0650.065 litres of fuel.

  2. 2Estimate

    y=1.2+0.065×150=10.95y = 1.2 + 0.065 \times 150 = 10.95 litres. Reliable: 150 km is within the data range.

  3. 3600 km

    Extrapolation far beyond 200 km: the estimate may be unreliable.

Answer

10.9510.95 litres; 600 km is extrapolation

Beyond the specification

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 nn deviations into vectors: x=(x1−xˉ,…,xn−xˉ)\mathbf x = (x_1 - \bar x, \ldots, x_n - \bar x) and y=(y1−yˉ,…,yn−yˉ)\mathbf y = (y_1 - \bar y, \ldots, y_n - \bar y) in Rn\mathbb R^n. Then

Sxx=∣x∣2,Syy=∣y∣2,Sxy=x⋅y,r=x⋅y∣x∣∣y∣=cos⁡θ,S_{xx} = |\mathbf x|^2,\qquad S_{yy} = |\mathbf y|^2,\qquad S_{xy} = \mathbf x\cdot\mathbf y,\qquad r = \frac{\mathbf x\cdot\mathbf y}{|\mathbf x||\mathbf y|} = \cos\theta,

where θ\theta is the angle between the two vectors. So the correlation coefficient is the cosine of an angle, which is why it lies between −1-1 and 11, and why it is unchanged by rescaling either variable (Q58): scaling a vector does not change its direction.

TheoremRegression as projection

The least-squares line of yy on xx has gradient b=x⋅yx⋅xb = \frac{\mathbf x\cdot\mathbf y}{\mathbf x\cdot\mathbf x}: bxb\mathbf x is the orthogonal projection of y\mathbf y onto the line spanned by x\mathbf x. The residual vector e=y−bx\mathbf e = \mathbf y - b\mathbf x is perpendicular to x\mathbf x.

Proof

The sum of squared residuals is ∣y−bx∣2|\mathbf y - b\mathbf x|^2, the squared distance from y\mathbf y to the point bxb\mathbf x on the line. The closest point is the foot of the perpendicular, where (y−bx)⋅x=0(\mathbf y - b\mathbf x)\cdot\mathbf x = 0, giving b=SxySxxb = \frac{S_{xy}}{S_{xx}}. ■\blacksquare

∎

Pythagoras in Rn\mathbb R^n now gives the analysis of variance for regression:

∣y∣2=∣bx∣2+∣e∣2,i.e.Syy=r2Syy+(1−r2)Syy.|\mathbf y|^2 = |b\mathbf x|^2 + |\mathbf e|^2,\qquad\text{i.e.}\qquad S_{yy} = r^2S_{yy} + (1 - r^2)S_{yy}.

The line "explains" a fraction r2=cos⁡2θr^2 = \cos^2\theta of the variation in yy, and the residuals carry the rest. With r=0.8r = 0.8, the line explains 6464% of the variation, not 8080%.

IntuitionMany variables at once

With several explanatory variables x(1),…,x(k)x^{(1)}, \ldots, x^{(k)}, least squares projects y\mathbf y onto the subspace they span. Writing the data as a matrix XX, the normal equations XTXβ=XTyX^{\mathsf T}X\boldsymbol\beta = X^{\mathsf T}\mathbf y say exactly that the residual is perpendicular to every column of XX. This is the foundation of linear models, used everywhere from economics to machine learning.

ExampleRegression to the mean

In standardised units (u=x−xˉσxu = \frac{x - \bar x}{\sigma_x}, v=y−yˉσyv = \frac{y - \bar y}{\sigma_y}) the regression line is simply v=ruv = ru. If ∣r∣<1|r| < 1, someone 22 standard deviations above average on xx is predicted to be only 2r2r standard deviations above average on yy. 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 uu on vv 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 r=1r = 1 into r=−0.45r = -0.45 with a single point). Robust statistics quantifies and fixes this.

DefinitionBreakdown point

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 1n\frac1n, effectively 00: one value can drag it anywhere.
  • Median: breakdown point 12\frac12: you must corrupt half the data to move it without limit. That is the best possible.
  • IQR: breakdown point 14\frac14.
  • Trimmed mean (drop the top and bottom 1010% and average the rest): breakdown point 0.10.1.
DefinitionInfluence of a single value

Adding a value xx to nn others moves the mean by x−xˉn+1\frac{x - \bar x}{n + 1}, which grows without limit in xx. The median moves by at most half the gap between neighbouring values, however large xx is. The influence function of a statistic records this effect as a function of xx: unbounded for the mean, bounded for the median.

MethodA robust spread: the MAD

The median absolute deviation is MAD=median⁡ ∣xi−median⁡(x)∣\text{MAD} = \operatorname{median}\,|x_i - \operatorname{median}(x)|. For normal data σ≈1.4826×MAD\sigma \approx 1.4826\times\text{MAD}, so 1.4826 MAD1.4826\,\text{MAD} is a robust estimate of the standard deviation. A common outlier rule flags values whose distance from the median exceeds 3×1.4826 MAD3\times1.4826\,\text{MAD}; unlike the xˉ±2σ\bar x \pm 2\sigma rule, the outliers cannot hide themselves by inflating σ\sigma.

IntuitionMasking

Why can the 2σ2\sigma rule fail? Large outliers inflate σ\sigma, widening the fences until the outliers fall inside them. By Samuelson's inequality (Q52), with n=10n = 10 no value can ever be more than 3σ3\sigma from the mean, so a "3σ3\sigma" rule could never flag anything. Rules built from the median and IQR or MAD do not suffer from this: the box plot's 1.5×1.5\timesIQR 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 π2≈1.57\frac\pi2 \approx 1.57 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.

ExampleAnscombe's quartet

In 1973 Anscombe published four data sets of 1111 points each with (to two decimal places) the same means of xx and yy, the same variances, the same correlation r=0.816r = 0.816 and the same regression line y=3.00+0.50xy = 3.00 + 0.50x. 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.)

TheoremSimpson's paradox

It is possible for a relationship to hold within every group and reverse when the groups are combined.

ExampleKidney stones

In a well-known 1986 study, treatment A succeeded in 8181 of 8787 small stones (9393%) and 192192 of 263263 large stones (7373%); treatment B in 234234 of 270270 small (8787%) and 5555 of 8080 large (6969%). A is better for both sizes, yet overall A succeeded in 273350=78\frac{273}{350} = 78% and B in 289350=83\frac{289}{350} = 83%. The reason: A was used mostly on large stones, which are harder to treat. The combined rate is a weighted average ∑gwgpg\sum_g w_gp_g, 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 xx also has larger yy overall. The combined SxyS_{xy} is the sum of the within-group parts and a between-group part,

Sxy=∑gSxy(g)+∑gng(xˉg−xˉ)(yˉg−yˉ),S_{xy} = \sum_g S_{xy}^{(g)} + \sum_g n_g(\bar x_g - \bar x)(\bar y_g - \bar y),

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?

IntuitionThe ecological fallacy

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 rr. 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?

Why does this work?Why divide by nn (and sometimes n−1n - 1)?

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 n−1n - 1 instead of nn (Bessel's correction) exactly removes this bias: E[1n−1∑(Xi−Xˉ)2]=σ2E\left[\frac{1}{n - 1}\sum(X_i - \bar X)^2\right] = \sigma^2.

Beyond the syllabus

Beyond the syllabusLeast squares regression

The regression line y=a+bxy = a + bx minimises ∑(yi−a−bxi)2\sum(y_i - a - bx_i)^2. Setting the partial derivatives with respect to aa and bb to zero gives b=SxySxxb = \frac{S_{xy}}{S_{xx}} and a=yˉ−bxˉa = \bar y - b\bar x, so the line always passes through (xˉ,yˉ)(\bar x, \bar y). The correlation coefficient is r=SxySxxSyyr = \frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}, and ∣r∣≤1|r| \le 1 follows from the Cauchy–Schwarz inequality.

Mathematical curiosities

ParadoxSimpson's paradox

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.

Mathematical curiosityAnscombe's quartet

Four data sets with the same means, variances, correlation (0.8160.816) 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.

Further exploration

Further explorationInvestigations
  • Prove that ∑(xi−c)2\sum(x_i - c)^2 is minimised when c=xˉc = \bar x, and ∑∣xi−c∣\sum|x_i - c| when cc is the median.
  • Find real data exhibiting Simpson's paradox (university admissions by department is a classic).
Now practise60 questions from Very easy to Extreme →