Free access until 31 December 2026 · Physics and Maths questions and notes, updated continuously · Build a test

4 · IB Maths

Scatter and regression

The least-squares line minimises the sum of the squared vertical distances to the points. Drag any point, click empty space to add your own, and watch r and the line respond. Show the residuals to see what "least squares" means.

Predict first

Start from the default settings. Drag Spread of data all the way down to 0. What is the correlation coefficient r?

Drag a point to move it. Click or tap empty space to add a point. Gold: data. Dark line: least-squares line. Rust: residuals.

ŷ = mx + b, m = Sxy ÷ Sxx, b = ȳ − m x̄
r = Sxy ÷ √(Sxx Syy)
SSE = Σ (y − ŷ)²
Regression line
Correlation r
r²
Sum of squared residuals
Points n

Try this

  1. Press "Strong positive", then "Weak negative". Compare r and r², and say what each tells you about the strength and direction of the relationship.
  2. Tick "Show residuals" and "Draw residuals as squares", then drag one point far from the line. Watch the sum of squared residuals as the line tilts towards it.
  3. Press "New sample", then "Add an outlier" and note how much r and the gradient change. Remove it again and compare.

Common error: using the regression line of y on x to predict x from y, or extrapolating far outside the data; the line minimises vertical distances, and a large r does not by itself prove that one variable causes the other.