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
| x | y | Line’s y | Residual (y − line) |
|---|---|---|---|
| 1 | 52 | 52.2381 | −0.2381 |
| 2 | 58 | 57.0095 | 0.9905 |
| 3 | 61 | 61.781 | −0.781 |
| 4 | 67 | 66.5524 | 0.4476 |
| 5 | 70 | 71.3238 | −1.324 |
| 6 | 77 | 76.0952 | 0.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.