Linear Regression Calculator
Fit a least-squares line to X/Y data and get slope, intercept, and R².
How it works
- 1Enter your X values and Y values as comma- or space-separated lists of equal length.
- 2The calculator applies ordinary least squares to minimise the sum of squared vertical residuals, yielding slope m and intercept b of y = mx + b.
- 3R² measures how well the line explains the variance in Y — 1 means a perfect fit; 0 means it explains none of the variation.
Use cases
- Analyse whether a business metric grows linearly with time or spend.
- Identify the trend in scientific measurements before deeper modelling.
- Validate a dataset before applying it to a model that assumes a linear relationship.
Frequently asked questions
What does the slope m represent?
The slope is the expected change in Y for every one-unit increase in X. A slope of 1.5 means Y rises by 1.5 each time X increases by 1.
What is a good R² value?
R² ranges from 0 to 1. Above 0.9 suggests a strong linear fit; below 0.5 means the line captures less than half the variance and another model may fit better.
Why does the result show —?
It is undefined when the X and Y lists differ in length, when fewer than 2 points are given, or when all X values are identical (zero variance, so the slope is indeterminate).
Related tools
See all →Calculate the area and perimeter of a rectangle from its width and height, with a labeled diagram.
Calculate the area and circumference of a circle from its radius, with a labeled diagram.
Calculate the area (Heron’s formula) and perimeter of a triangle from its three sides.
Calculate the area and perimeter of a trapezoid from its two parallel sides, height, and legs.