Linear Regression Calculator

Fit a line of best fit to paired data and find its slope, intercept, and correlation. Enter the x and y values as two lists.

Best-Fit Line
Least-squares fit.

Usage Tip

An r near plus or minus 1 means points hug the line; near 0 means little linear relationship. Correlation is not causation.

THE MATH
slope = covariance of x and y ÷ variance of x
intercept = mean y − slope × mean x
Linear regression finds the straight line that best predicts y from x by least squares.
The correlation coefficient r, from −1 to 1, measures how strong and in which direction the relationship is.
Enter two equal-length lists of numbers.
The slope, intercept, and correlation r are reported.
r squared is the share of variation in y explained by x.
Scroll to Top

The calculators and tools on Formula Factory are provided for general guidance and informational purposes only. Results are estimates based on standard formulas and the values you enter — they do not constitute professional engineering, electrical, or architectural advice. Always verify calculations with a qualified professional before making decisions for any safety-critical, code-compliance, or commercial application. Formula Factory makes no representations or warranties as to the accuracy or completeness of any result, and accepts no liability for errors, omissions, or any outcomes arising from reliance on this information.