Arithly

← All maths topics

Correlation and the regression line

A scatter plot shows whether two variables move together; Pearson's correlation coefficient r measures how strongly they follow a straight line. It is built from three sums — Sxy (how x and y move together), Sxx and Syy (their separate spreads) — as r = Sxy/√(Sxx·Syy). The value always lies between −1 and 1: near 1 means strong positive association, near −1 strong negative, near 0 no linear pattern. Remember that correlation is not causation: r says nothing about WHY the variables move together.

The regression line of y on x is the least-squares line of best fit, y = a + bx, used to predict y from a given x. Its slope is b = Sxy/Sxx and it always passes through the point of averages (x̄, ȳ), which fixes the intercept a = ȳ − b·x̄. Predictions are trustworthy inside the range of the data and risky outside it — the line has no evidence beyond the points it was fitted to.

Think first

Before reading the solution, try to answer these — they are the hints Arithly itself gives:

Worked example

Find the equation of the regression line of y on x for the data x: 1, 2, 3, 4 and y: 3, 5, 6, 8

  1. Set out the pairs in a table and multiply across each row (xy, x^2 and y^2 are needed for the formulas):
  2. Row 1: x = 1, y = 3 → xy = 3, x^2 = 1, y^2 = 9.
  3. Row 2: x = 2, y = 5 → xy = 10, x^2 = 4, y^2 = 25.
  4. Row 3: x = 3, y = 6 → xy = 18, x^2 = 9, y^2 = 36.
  5. Row 4: x = 4, y = 8 → xy = 32, x^2 = 16, y^2 = 64.
  6. Add the columns: n = 4, Σx = 10, Σy = 22, Σxy = 63, Σx^2 = 30, Σy^2 = 134. The means are x̄ = Σx/n = 5/2 (≈ 2.5) and ȳ = Σy/n = 11/2 (≈ 5.5).
  7. Three centred sums drive everything: Sxy = Σxy - (Σx)(Σy)/n measures how x and y move TOGETHER, Sxx = Σx^2 - (Σx)^2/n measures the spread of x, and Syy likewise for y. Here Sxy = 63 - 55 = 8, Sxx = 30 - 25 = 5, Syy = 134 - 121 = 13.
  8. Pearson's correlation coefficient is r = Sxy / sqrt(Sxx × Syy) = 8 / sqrt(5 × 13) = 8 / 8.0623 ≈ 0.9923. This is a strong positive correlation: as x increases, y tends to increase. (r is always between -1 and 1, and it measures straight-line association only.)
  9. The regression line of y on x (the least-squares line of best fit) is y = a + bx, where the slope is b = Sxy/Sxx = 8 / 5 = 8/5 (≈ 1.6) and the constant is a = ȳ - b*x̄ = 11/2 - 8/5 × 5/2 = 3/2 (≈ 1.5). So the line is y = 8x/5 + 3/2.

Answer: r ≈ 0.9923; Regression line of y on x: y = 8x/5 + 3/2

Practice

Try these yourself. Each one opens in Arithly with the question already filled in — solve it there and check your working:

Related topics

Grouped Statistics

Data in class intervals: means and medians for grouped tables.

Variance and Standard Deviation

Spread around the mean — the other half of describing data.

Standard Deviation Calculator

Mean and standard deviation for any data set, worked in full.

Mean, Median & Mode

The averages that scatter graphs summarise.

Sampling & Margin of Error

How much a sample can be trusted — uncertainty quantified.

More topics: all maths topics · Next topic: Sets and Venn diagrams

© 2026 Arithly. Content: CC BY-NC 4.0 · Code & solver: all rights reserved.