Part of the Maths & Statistics suite · 235 calculators

Linear Regression Calculator

The line of best fit through paired data — slope, intercept, r², and a prediction for any value of x.

Least-squares regression finds the straight line that minimises the total squared vertical distance from the points.

Results update as you type
Results
Slope
0.904762
Intercept
Line of best fit
r² — variance explained
Predicted y
Residual standard error
Reviewed September 2026. Pure mathematics: the result does not depend on where you are. Terminology follows the national curriculum (maths, brackets, decimal point).
No account required · Google Analytics off unless allowedCalculator arithmetic runs in your browserResults update as you type
All calculations run 100% in your browser. The calculator code does not submit your figures to GlobalCalc to obtain a result.
About linear regression

How the linear regression calculator works

Least-squares regression finds the straight line that minimises the total squared vertical distance from the points. The slope is the covariance divided by the variance of x, and the line always passes through the mean of both variables, which is a useful check.

The slope is the interpretable number: it says how much y changes for a one-unit rise in x. r² says how much of the variation the line accounts for. Predicting outside the range of your data is extrapolation, and the line has no evidence for it whatever the arithmetic returns.

Formula: slope = Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)²; intercept = ȳ − slope × x̄

Worked examples

InputsSlopeNote
A rising trend0.904762slope ≈ 0.86
A perfect line y = 2x + 12slope exactly 2
A falling trend-2slope −2

Frequently asked questions

What does the slope mean?

How much y changes for a one-unit increase in x. It is the number worth interpreting.

What is least squares?

The line that minimises the total squared vertical distance from the points to the line.

What is a good r²?

It depends entirely on the field. In physics 0.99 may be poor; in social science 0.3 can be a real finding.

Can I predict beyond my data?

The arithmetic will, but the evidence does not. The calculator flags it when your prediction falls outside the range of your x values.

Does a good fit prove causation?

No. A line through correlated data says nothing about which variable drives which, or whether a third does.

Where these figures come from

Last checked: September 2026. Formulas are fixed by mathematics and do not change with tax years or regulations.