Linear Regression Calculator
Fit a least-squares line to paired data. Free linear regression calculator giving slope, intercept, r-squared, the equation and predictions.
What you enter in this tool and its results may be saved and used to improve AI Walay tools. Please don't enter passwords or private personal details.
About the Linear Regression Calculator
Linear regression fits the straight line that best predicts y from x by minimising the squared vertical distances to the data. This free linear regression calculator takes your paired x and y values and returns the slope, the intercept, the full equation y = mx + b, the correlation r and the coefficient of determination r-squared.
The slope is m = Σ((x − x̄)(y − ȳ)) ÷ Σ(x − x̄)², and the intercept is b = ȳ − m·x̄. Once you have the equation you can predict y for any new x. R-squared tells you how well the line fits: 1 is a perfect fit, 0 means the line explains none of the variation.
Students, data analysts and researchers use regression to model trends and make predictions — sales versus advertising, height versus weight, temperature versus energy use.
How to Use the Linear Regression Calculator
- 1Enter your x values and your y values as matched lists.
- 2Ensure both lists have the same count of numbers.
- 3Read the slope, intercept and the equation of the best-fit line.
- 4Enter a new x value to predict its y, and check r-squared for fit quality.
Frequently Asked Questions
How do I calculate the line of best fit?
Compute the slope m = Σ((x − x̄)(y − ȳ)) ÷ Σ(x − x̄)² and the intercept b = ȳ − m·x̄. For points (1,2), (2,4), (3,5), (4,4), (5,5) the best fit is y = 0.6x + 2.2. The calculator does the arithmetic for any dataset.
What does r-squared tell me?
R-squared is the fraction of the variation in y explained by the line. An r-squared of 0.85 means 85% of the variability in y is accounted for by x; the remaining 15% is unexplained scatter. Higher is a better fit, but always plot the data to check.
How do I use the regression equation to predict?
Substitute a new x into y = mx + b. With y = 0.7x + 1.5, predicting for x = 6 gives 0.7 × 6 + 1.5 = 5.7. Be cautious predicting far outside the range of your data — the linear pattern may not hold.
What is the difference between correlation and regression?
Correlation (r) measures the strength and direction of a linear relationship as a single number between −1 and 1. Regression produces the actual line — slope and intercept — so you can make predictions. They are related: r-squared is literally r multiplied by itself.
How many data points do I need for regression?
Technically two, but a line through two points always fits perfectly and tells you nothing about reliability. Aim for at least 10-30 pairs so the slope and r-squared are meaningful and less swayed by a single outlier.
Cite this tool
Using this tool in a paper, report or project? Copy a ready-made citation.
AI Walay. (2026). Linear Regression Calculator [Online tool]. AIWalay Tools. https://aiwalay.pk/tools/calculators/linear-regression-calculator/