Lines of Best Fit

One line drawn through the middle of the cloud, then read like any other line: slope and intercept, with units.

The cloud drifts upward, but no single line goes through every dot. So which line do you draw?

lay a ruler through the middle of the cloud roughly half the dots sit above the ruler, half below

Lay a ruler through the middle of the cloud. Roughly half the dots should end up above it and half below.

The little gaps are the misses — how far each real child sat from what the line predicted.

A good line keeps those gaps small and balanced. A line dragged towards one stray dot makes most of the other gaps worse.

That is all a line of best fit is: a summary. Its slope tells you the typical gain per extra hour, and its intercept the predicted score at zero hours — both with units, and neither one a claim about cause.

A line of best fit through a scatter plot the line of best fit runs through the middle of the cloud hours practised score roughly half above, half below use it to predict inside the data, not far outside it a trend is not a cause — both may be following something else entirely

Drawing the line

Aim for the middle of the cloud, with roughly half the dots above and half below, following the direction of the pattern.

It does not have to touch any dot. It must not be dragged by a single outlier.

Draw it right across the plot with a ruler so you can read off values at either end.

Squint at the plot

Step back and half-close your eyes so the dots blur into a band. Draw your line down the middle of that band. This works better than any amount of point-by-point fiddling.

Finding its equation

Pick two points on your line — not two data points — that sit on convenient grid crossings.

Find the slope from them, read the y-intercept, and write y = mx + b.

Two people will get slightly different lines from the same data. Both can be right.

Use the line, not the dots

The whole point of the line is that it smooths out the dots. Computing the slope from two raw data points defeats it.

Saying what the numbers mean

The slope is the predicted change in y for every one-unit increase in x — with units attached.

"The slope is 4.5" is half an answer. "Each extra hour of practice is associated with about 4.5 more points" is a full one.

The intercept is the prediction when x = 0. Sometimes that is meaningful; sometimes it is nonsense, like a newborn weighing -2 kg.

"Associated with", not "causes"

The line is a summary of what happened together. It still does not establish cause.

Predicting, and knowing when not to

Substitute an x inside the data range and read off the prediction. That is interpolation, and it is reasonable.

Substituting an x far outside the range is extrapolation. The pattern may simply stop holding.

A line fitted to children aged 5 to 12 will confidently predict that a 40-year-old is 3 metres tall. The arithmetic is fine; the prediction is nonsense.

Worked examples

Equation from a fitted line

A line of best fit passes through (0, 20) and (10, 65). Write its equation.

  1. b = 20, from the point with x = 0. That is the y-intercept.
  2. m = 65 - 2010 - 0 = 4510 = 4.5 Rise over run between the two line points.
  3. y = 4.5x + 20 Slope-intercept form.

y = 4.5x + 20

Interpreting the slope

For y = 4.5x + 20, where x is hours practised and y is score, what do 4.5 and 20 mean?

  1. The slope 4.5 is points per hour. Units of y divided by units of x.
  2. Each additional hour of practice is associated with about 4.5 more points. Say "associated with", not "causes".
  3. The intercept 20 predicts the score with no practice at all. Meaningful here, since zero hours is possible.

4.5 points per hour; 20 points predicted with no practice

When prediction fails

The data covers 0 to 10 hours. Use y = 4.5x + 20 to predict the score after 40 hours, and comment.

  1. y = 4.5(40) + 20 = 200 The arithmetic is straightforward.
  2. But 40 is far outside the 0–10 range. That is extrapolation.
  3. And a score of 200 is likely impossible anyway. Most tests stop at 100.
  4. So the prediction is not trustworthy. The linear pattern almost certainly flattens out.

200 — arithmetically correct, but an unsafe extrapolation

Words to know

Line of best fit
A straight line summarising a linear pattern in a scatter plot.
Interpolation
Predicting inside the range of the data. Usually safe.
Extrapolation
Predicting outside the range. Risky.
Residual
The gap between an actual value and the line's prediction.

Mistakes to watch for

Computing the slope from two data points. The whole purpose of the line is to smooth out individual dots, so its slope must come from two points on the line — ideally on grid crossings, far apart.

Tilting the line to chase an outlier. One unusual dot should not move the summary of the other twenty. If your line no longer splits the cloud in half, it is being pulled.

Giving the slope as a bare number. "4.5" is half an answer; "about 4.5 more points for each extra hour of practice" is a whole one. Slope is a rate, and a rate without units means nothing.

Extrapolating far beyond the data and trusting it. A line fitted to children aged 5 to 12 will confidently predict a 40-year-old is three metres tall. The arithmetic is fine — the assumption that the pattern continues is not.

The least-squares method — choosing the line that makes the squared gaps as small as possible — was published by Legendre in 1805.

Gauss then claimed he had been using it since 1795, which caused a long and bitter priority dispute.

Gauss had used it for something spectacular: predicting where the lost asteroid Ceres would reappear. Astronomers pointed their telescopes where he said, and there it was.

Browse all courses