RegressLab
Linear Regression Calculator
The straight line that best predicts y from x.
Best-fit lines for sample paired datasets
Paste the X and Y lists into the two input boxes exactly as written and this calculator returns the same least-squares slope and intercept. Both lists must hold the same number of values.
| X values | Y values | Slope (m) | Intercept (b) | Best-fit line |
|---|---|---|---|---|
| 1, 2, 3, 4, 5 | 2.1, 3.9, 6.2, 7.8, 10.1 | 1.99 | 0.05 | y = 1.99x + 0.05 |
| 1, 2, 3, 4 | 3, 5, 7, 9 | 2 | 1 | y = 2x + 1 |
| 0, 1, 2, 3 | 1, 3, 4, 8 | 2.2 | 0.7 | y = 2.2x + 0.7 |
| 5, 10, 15, 20 | 12, 19, 31, 38 | 1.8 | 2.5 | y = 1.8x + 2.5 |
| 10, 20, 30, 40, 50 | 50, 80, 95, 120, 140 | 2.2 | 31 | y = 2.2x + 31 |
| 2, 4, 6, 8, 10 | 55, 62, 71, 78, 89 | 4.2 | 45.8 | y = 4.2x + 45.8 |
| 1, 2, 3, 4, 5 | 10, 8, 6, 4, 2 | -2 | 12 | y = -2x + 12 |
| 1, 2, 3, 4, 5 | 7, 7, 7, 7, 7 | 0 | 7 | y = 0x + 7 |
The slope is how much y moves for each 1-unit rise in x, and the intercept is the predicted y at x = 0, which is often outside the range of the data and should not be read as a real-world baseline. The last row is flat: y never changes, so the slope is 0. A best-fit line always exists, even when the relationship is weak, so check a scatter plot before trusting a prediction.
Least-squares, in plain terms
Linear regression finds the line that minimizes the total squared vertical distance between the line and every data point — it's the 'best compromise' line through scattered data.
Reading the slope and intercept
The slope tells you how much y changes for every 1-unit increase in x, and the intercept is the predicted y-value when x is zero — together they let you predict y for any new x value.
Frequently asked questions
Ad spend ($K) vs revenue ($K): (10,50), (20,80), (30,95), (40,120), (50,140). What's the best-fit line?
The regression gives y = 2.2x + 31. Slope = 2.2 means each additional $1K in ads predicts $2.2K more revenue. Intercept = 31 means the model estimates $31K revenue at zero ad spend — but x = 0 sits outside the data range, so read it as the line's fitted constant rather than a real baseline forecast.
What is R² and how do I interpret it?
R² (coefficient of determination) is the proportion of variance in y explained by x. R² = 0.85 means the model explains 85% of the variation in y. The remaining 15% is unexplained. R² ranges from 0 (no fit) to 1 (perfect fit). It's the square of the correlation coefficient r.
How is linear regression different from correlation?
Correlation tells you HOW STRONGLY x and y are related (a single number from −1 to +1). Regression tells you the EQUATION for predicting y from x (slope and intercept). Correlation is symmetric (x↔y gives the same r); regression is not (predicting y from x ≠ predicting x from y).
Related Math calculators
Confidence Interval Calculator
Confidence interval for a sample mean.
OpenMargin of Error Calculator
Margin of error for a sample proportion (e.g. polling).
OpenQuartiles & IQR Calculator
Q1, Q2, Q3, interquartile range, and outlier fences.
OpenSkewness Calculator
Measure the asymmetry of a dataset's distribution.
OpenYou might also like
Ideal Gas Law Calculator
ScienceSolve PV = nRT for pressure given volume, moles, and temperature.
OpenFreezing Point Depression Calculator
ScienceHow much a dissolved solute lowers a solution's freezing point.
OpenRadioactive Decay Calculator
ScienceRemaining amount of a radioactive substance after a given time, from its half-life.
OpenLast updated: September 6, 2026