Overview

Linear regression finds the straight line that best fits your data, so you can describe the trend and predict new values.

Paste your x-y points, one per line. Add an x value if you want a prediction.

Worked examples

InputsResult
Your x-y points1, 2.2 · 2, 4.1 · 3, 5.8 · 4, 8.3 · 5, 9.9 · 6, 12.2y = 1.9971x + 0.093333R²: 0.9973 from 6 points

How it works

The line is chosen by least squares, which makes the squared vertical distances from the points to the line as small as possible. R² shows the share of the variation in y the line explains, from 0 to 1.

The formula

y = mx + b
mSlope: how much y changes for each step in x
bIntercept: y when x is 0

Practical tips

  • Look at the chart as well as R². A curved pattern can still score a high R².
  • Predicting far outside your x range is risky, because the trend may not continue.
  • One extreme point can pull the whole line toward it.

Frequently asked questions

What is a good R²?

It depends on the field. Close to 1 means the line explains most of the variation, but check the chart too.

Does a strong fit prove cause and effect?

No. It shows the two move together, not that one causes the other.

How many points do I need?

At least two, though a fit through two points always looks perfect. More points give a far more reliable line.