Linear Regression Calculator
Fits a straight line through paired data using least squares, returning the slope, the intercept, the r squared value, and the equation written out as y = mx + b. Enter one "x, y" pair per line.
Fits a straight line through paired data using least squares, returning the slope, the intercept, the r squared value, and the equation written out as y = mx + b. Enter one "x, y" pair per line.
Use cases
- Finding the trend line through a set of measurements
- Getting the equation to predict a value from a known input
Examples
Four pairs
1, 3 2, 5 3, 8 4, 10
{"n": 4, "slope": 2.4, "intercept": 0.5, "r_squared": 0.9931, "equation": "y = 2.4x + 0.5"}FAQ
Is my data sent to a server?
Yes — the calculation runs on the server for this tool.
What does r squared tell me?
How much of the variation in y the line accounts for, from 0 to 1. It is reported as null when every y value is identical, because there is then no variation for the line to explain.
Why can it not fit my data?
A line of the form y = mx + b needs at least two different x values. Points sharing a single x form a vertical line, which has no slope.