Linear Regression Calculator
Enter paired X and Y values to find the line of best fit.
This result is an estimate only. Double-check important figures before relying on them.
How it is calculated
- Slope b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²
- Intercept a = ȳ − b × x̄
- r² = the share of variation in Y explained by the line
For the correlation on its own, use the correlation calculator.
Worked example
X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5:
- Slope = 0.6, intercept = 2.2, so y = 2.2 + 0.6x
- At x = 6, the prediction is 5.8
Why your number may differ
A straight line is only suitable if the pattern is roughly linear. A few extreme points can pull the line a long way.
Frequently asked questions
What does the calculator find?
The least-squares line y = a + bx that minimises the squared vertical distance to your points, with its slope, intercept and r².
How good is the fit?
Look at r². Close to 1 means the line explains almost all the variation. Close to 0 means it explains very little.
Can I predict beyond my data?
You can, but be careful. Predictions far outside the range of your X values are unreliable.