Line of Best Fit Calculator

Find the line of best fit (least-squares regression) for a set of points: equation y = mx + b, correlation r, r², predictions and residuals (grade 8 and statistics).

Separate with commas or spaces
Same number of values as x, in the same order

Results

Line of best fit
y = 4.77143x + 47.4667
Predicted y at x = 8
85.6381
Slope (m)
4.77143
y-intercept (b)
47.4667
Correlation (r)
0.9945
r² (fit explained)
98.9%
Relationship
Strong positive correlation
xyLine’s yResidual (y − line)
15252.2381−0.2381
25857.00950.9905
36161.781−0.781
46766.55240.4476
57071.3238−1.324
67776.09520.9048
⚠️ x = 8 is outside your data (1 to 6). Predicting outside the data (extrapolation) is less reliable — the trend may not continue.
💡 x̄ = 3.5, ȳ = 64.1667; m = 83.5 ÷ 17.5 = 4.77143; b = 64.1667 − 4.77143 × 3.5 = 47.4667.
💡 Meaning of the slope: each time x goes up by 1, y goes up by about 4.771 on average.
💡 Correlation is not causation: two things can rise together without one causing the other.

Formula

Least squares: m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)², b = ȳ − m·x̄, r = Σ(x − x̄)(y − ȳ) / √(Σ(x − x̄)²·Σ(y − ȳ)²)

Rules of thumb

  • Plot the points first: if they curve, a straight line is the wrong model even when r looks high.

More Math calculators