Linear Regression Calculator
Find the best-fit line y = mx + b from your data points.
This tool is for informational and educational purposes only. It is not a substitute for professional financial, medical, legal, or engineering advice. See Terms of Service.
Can't find what you need?
Request a ToolHow to Use the Linear Regression Calculator
Enter your X values in the first box and Y values in the second box, separated by commas or spaces. Both lists must have the same number of values (at least 2). The calculator fits a line y = mx + b using the ordinary least squares method and displays the equation, slope, intercept, R-squared, and correlation coefficient.
The R-squared value indicates how well the line fits your data, ranging from 0 (no fit) to 1 (perfect fit).
About Linear Regression
Linear regression finds the straight line that best fits a set of data points by minimizing the sum of squared residuals. It is one of the most widely used statistical methods for modeling relationships between variables. The slope tells you how much Y changes for each unit increase in X, and the intercept is the predicted Y value when X is zero.
Frequently Asked Questions
How many data points do I need?
You need at least 2 points to fit a line, but more data gives more reliable results. For meaningful statistical inference, 20 or more points is recommended.
What does a negative slope mean?
A negative slope means Y decreases as X increases. For example, a slope of -2.5 means for each unit increase in X, Y decreases by 2.5 units on average.
When should I use a different type of regression?
If your data follows a curve, try quadratic, polynomial, or exponential regression instead. A low R-squared value or a clear pattern in the residuals suggests a non-linear model may fit better.