GintiCalcEvery calculation

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 valuesY valuesSlope (m)Intercept (b)Best-fit line
1, 2, 3, 4, 52.1, 3.9, 6.2, 7.8, 10.11.990.05y = 1.99x + 0.05
1, 2, 3, 43, 5, 7, 921y = 2x + 1
0, 1, 2, 31, 3, 4, 82.20.7y = 2.2x + 0.7
5, 10, 15, 2012, 19, 31, 381.82.5y = 1.8x + 2.5
10, 20, 30, 40, 5050, 80, 95, 120, 1402.231y = 2.2x + 31
2, 4, 6, 8, 1055, 62, 71, 78, 894.245.8y = 4.2x + 45.8
1, 2, 3, 4, 510, 8, 6, 4, 2-212y = -2x + 12
1, 2, 3, 4, 57, 7, 7, 7, 707y = 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

You might also like

Last updated: September 6, 2026