Line of Best Fit Calculator

Find the straight line that best fits your points by least squares. You get the slope, intercept, R² and a graph. For p-values, prediction intervals and residual plots, use the full linear regression calculator.

m = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², b = ȳ − m·x̄

How least squares works

The line of best fit is the line that makes the sum of the squared vertical distances from the points to the line as small as possible. Squaring treats points above and below the line equally and penalises large misses more than small ones.

Use the line to describe the trend and to predict y for x values within your data range. Predictions far outside that range (extrapolation) are unreliable.