Skip to content
math

Linear Regression Calculator

Fit a least-squares line to X/Y data and get slope, intercept, and R².

Slope (m)
0.8
Intercept (b)
1.8
0.7273
Best-fit line
y = 0.8x + 1.8

How it works

  1. 1Enter your X values and Y values as comma- or space-separated lists of equal length.
  2. 2The calculator applies ordinary least squares to minimise the sum of squared vertical residuals, yielding slope m and intercept b of y = mx + b.
  3. 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).

See all →