UTILS.
Private by default
📉

Linear Regression Calculator

Find the least-squares regression line y = a + b·x from paired data, with slope, intercept, r, r-squared and predictions.

Your files stay on this device

Files are processed in your browser, never uploaded. The site downloads code and assets to run the tools. No accounts or trackers.

Use Download to save this tool as one HTML file for offline use.

Privacy →

One pair per line — separate x and y with a comma, space or tab. Lines without two numbers are skipped.

About this tool

The Linear Regression Calculator fits a straight line to your paired (x, y) data using the ordinary least-squares method, entirely in your browser — nothing you paste is ever uploaded. Enter one pair per line as "x, y" (commas, spaces or tabs all work) and it returns the best-fit line plus its goodness-of-fit statistics live as you type.

It first computes the means x̄ and ȳ, then the sums of squares Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)² and the cross term Sxy = Σ(x − x̄)(y − ȳ). The slope is b = Sxy / Sxx and the intercept is a = ȳ − b·x̄, giving the line y = a + b·x. The correlation coefficient r = Sxy / √(Sxx·Syy) and its square r² measure how well the line explains the data.

Type a value in the "predict" field to get the fitted ŷ = a + b·x for that x. Lines that do not contain two readable numbers are skipped, so you can paste messy data; you need at least two valid points, and the x values must not all be identical.

Frequently asked questions

What method does it use?
Ordinary least squares: it minimises the sum of squared vertical residuals, giving slope b = Sxy/Sxx and intercept a = ȳ − b·x̄, where Sxy and Sxx are the cross-product and x sum-of-squares about the means.
What does r² tell me?
r² (the coefficient of determination) is the fraction of the variation in y explained by the line — 1 is a perfect fit, 0 means the line explains nothing. It equals the square of the correlation coefficient r.
How do I format the data?
One (x, y) pair per line, with the two numbers separated by a comma, space or tab. Lines without two valid numbers are ignored, so headers or stray text won't break it.
Why do I get an invalid result?
You need at least two valid points, and the x values cannot all be the same — a vertical line has no defined slope, so Sxx would be zero and the least-squares fit is undefined.

More tools