Linear Regression Calculator
Find the best-fit line equation and R² for your x,y data.
Free Linear Regression Calculator
Our free linear regression calculator fits a straight line to your x,y data using the least-squares method, giving you the slope, y-intercept, and full equation in the form y = mx + b. It also computes R² (the coefficient of determination) and r (the Pearson correlation coefficient), so you can judge how well the line actually fits your data.
Paste your data pairs one per line as "x,y", and the scatter plot updates instantly with the fitted regression line drawn through it. Once you have a fit, enter any x value to get its predicted y from the regression equation — useful for forecasting or interpolating between data points.
Built for statistics students working through regression analysis, and for anyone who needs a fast, reliable best-fit line without spreadsheet formulas. No sign-up, no downloads — just instant results.
About the Linear Regression Calculator
How It Works & Methodology
The Linear Regression Calculator fits a straight line to a set of x,y data points using ordinary least squares, giving you the slope, intercept, and full equation, along with R² and the Pearson correlation coefficient to judge fit quality. A scatter plot shows your data and the fitted line together, and you can predict y for any x using the resulting equation.
Features
Least-squares fit
The standard method for fitting a straight line to scattered data.
R² and correlation
See both the coefficient of determination and Pearson's r.
Live scatter plot
Data points and the regression line update as you edit.
Prediction
Enter any x to get its predicted y from the fitted line.
Related Calculators & Tools
Calculate population and sample standard deviation with full step-by-step working, plus mean, variance, and more from your data set.
Paste a data set and get all descriptive statistics plus a histogram.
Convert between a z-score and a percentile with a shaded bell curve.
Calculate a confidence interval for a mean (z or t interval) or proportion, with margin of error and critical value shown step by step.
Authoritative Sources & Standards
- NIST/SEMATECH e-Handbook of Statistical Methods — National Institute of Standards and Technology (NIST)
- ISO 3534-1: Statistics — Vocabulary and Symbols — International Organization for Standardization (ISO)
Frequently Asked Questions
How do I enter data?
One x,y pair per line, e.g. 1,2 then 2,3.9 on the next line.
What method does it use?
Ordinary least squares, which minimizes the sum of squared vertical distances between the data points and the fitted line.
What does R² mean?
The coefficient of determination, from 0 to 1, showing what fraction of the variation in y is explained by the linear relationship with x. Closer to 1 means a better fit.
What's the difference between R² and r?
r is the Pearson correlation coefficient (-1 to 1), showing direction and strength of the linear relationship. R² is r squared, showing the proportion of variance explained.
How does the prediction work?
Enter any x value and the tool evaluates the fitted equation y = mx + b at that x.
How many data points do I need?
At least 2, though more points give a more reliable fit.
What if all my x values are the same?
A vertical line has no defined slope in y = mx + b form, so the calculator shows an error in that case.
Does it handle negative numbers?
Yes, both x and y can be negative, positive, or decimal values.