Want a Custom tool for Yourself?

Need a Custom Tool? We build custom tools that can save hours per employee per day.

Linear Regression Calculator

Run linear regression on x,y pairs to get slope, intercept, and best fit line. Useful for trend checks, prediction, and quick homework validation.

Enter the Details



Result will appear here...


Last updated: April 17, 2026

Created by: Eon Tools Dev Team

Reviewed by: Ankit Khatiwada



What the linear regression calculator does

Linear regression finds the straight line that best fits a set of paired data. This calculator takes your x and y points, works out the slope and intercept of that best-fit line, gives its equation, and reports how well the line matches the data. It also plots the points and the line together so you can see the fit.

It is the standard tool for spotting a trend and using it to predict. Below is how the line is found and how to read what comes back.

How to use it

  1. Enter your data as x,y pairs in the box, separated by spaces or new lines, at least three of them.
  2. Press Calculate for the slope, intercept, equation, R-squared, and a plot, or Reset to clear it.

The idea of least squares

For any line you might draw through a scatter of points, each point sits some vertical distance above or below it. That distance is the error the line makes for that point. The best-fit line is the one that makes those errors smallest overall, and specifically the one that minimises the sum of their squares.

Squaring the errors before adding them does two things: it treats distances above and below the line the same, and it penalises big misses more than small ones. The line that makes this squared total as small as possible is the least squares regression line, and there is exactly one of them for any set of points, which is what the calculator computes.

Reading the slope and intercept

The line is described by two numbers. The slope is how much y changes for each one-unit increase in x. A slope of 0.9 means that every step right along x lifts the predicted y by 0.9. Its sign tells the direction: positive slopes rise, negative slopes fall.

The intercept is the predicted value of y when x is zero, where the line crosses the vertical axis. Sometimes that is meaningful and sometimes it is just where the line lands, especially if x never actually gets near zero in your data. Together the slope and intercept let you predict y for any x, by putting it into the equation.

What R-squared tells you

The slope and intercept give you the best line, but not how good that line is. That is the job of R-squared, the coefficient of determination. It runs from 0 to 1 and measures the fraction of the variation in y that the line accounts for.

An R-squared of 0.81 means the line explains 81 percent of the ups and downs in y, leaving 19 percent to everything else. Closer to 1 is a tighter fit, with points hugging the line, while closer to 0 means the line captures little and the points scatter widely around it. It is the single number to glance at when judging whether a straight line is a good description of the data.

Correlation is not causation

This is the caution that matters most. A strong fit shows that two things move together, but it does not prove that one causes the other. Ice cream sales and drowning both rise in summer, and a regression would link them tightly, yet neither causes the other. A third factor, the warm weather, drives both.

So a good regression line is evidence of a relationship, not of a mechanism. Before reading a slope as an effect, it is worth asking whether something else could be behind both variables, whether the direction of cause could run the other way, and whether the link would survive outside the range of the data. The line describes what the data does, not why.

A worked example

Suppose you enter the five points (1, 2), (2, 3), (3, 5), (4, 4), and (5, 6). The calculator finds a best-fit line of y = 0.9x + 1.3, with an R-squared of about 0.81.

Reading that: each one-unit rise in x is linked to a 0.9 rise in y, the line meets the vertical axis at 1.3, and the line explains about 81 percent of the variation in y, a fairly strong fit. To predict y at x equals 6, put it in: 0.9 times 6 plus 1.3 = 6.7. The plot would show the five points with the line running through their middle.

Entering your data

Enter at least three x,y pairs, separated by spaces or new lines, with each pair written as two numbers with a comma between them. The calculator returns the slope, the intercept, the full equation, R-squared, and a scatter plot with the fitted line. More points spread across a range give a more trustworthy line than a few clustered together.

Questions people ask

What is linear regression?

A method for finding the straight line that best fits paired data, by minimising the squared vertical distances from the points to the line. It gives a slope, an intercept, and an equation for prediction.

What does the slope mean?

How much y changes for each one-unit increase in x. A positive slope rises, a negative slope falls, and its size is the rate of change.

What is a good R-squared?

Closer to 1 means a tighter fit, with the line explaining more of the variation in y. What counts as good depends on the field, but higher is a better description of the data.

Does a good fit prove causation?

No. A strong fit shows the variables move together, not that one causes the other. A hidden third factor, or a reversed direction of cause, can produce a strong link without any direct effect.

References

A quick note on where the methods here come from. Least squares linear regression and the coefficient of determination are set out in the NIST/SEMATECH e-Handbook of Statistical Methods, the US government's public statistics reference. OpenStax Introductory Statistics is a free, widely used textbook covering linear regression and correlation.

  1. NIST/SEMATECH e-Handbook of Statistical Methods (linear least squares regression). https://www.itl.nist.gov/div898/handbook/
  2. OpenStax, Introductory Statistics (linear regression and correlation). https://openstax.org/details/books/introductory-statistics-2e


Ankit Khatiwada

Ankit Khatiwada is a researcher and graduate student in Computer Science at Saarland University, with strengths in statistics, data analysis, data engineering, and full stack development. His work sits at the intersection of quantitative reasoning and applied technology, making him a strong fit for tools that depend on clear numerical logic. At Eon Tools, he reviews number and statistical tools.