Linear Regression Calculator
Enter your x and y values to fit a straight line and predict new values.
Numbers separated by commas, spaces or new lines.
One y for each x, in the same order.
Optional: an x value to predict y for.
Result
You entered
Slope
Intercept
r
r²
Show the work
Means of x and y
Each value is measured from the mean of its own variable, so the means come first. There are pairs.
Sums of squares and products
measures how spread out the x values are, and how x and y move together: it is positive when they rise together and negative when one rises as the other falls.
Using
Slope of the least-squares line
The line of best fit is the line that makes the sum of the squared vertical distances to the points as small as possible. Its slope is the shared movement of x and y divided by the spread of x.
Intercept of the least-squares line
The best-fit line always passes through the point of means, so the intercept follows from putting and into .
Equation of the line of best fit
Putting and into the equation of a line gives .
Using
Result
So the line of best fit is .