Scatter Plot & Regression

Paste x and y, get the line of best fit — plus polynomial, exponential, logarithmic and power models, ranked by how well they actually fit.

Instant answers Works offline once loaded Nothing you type is sent anywhere Scatter and fit Models ranked by R² Predict from the fit
Separate x from y with a space, a comma or a tab. Two columns pasted from a spreadsheet work unchanged.

Models, best fit first

Higher degrees fit the points more closely and generalise worse.
Applies to the linear model only.

Line of best fit

R² — variance explained
r — correlation
Standard error of estimate
Points
Mean x
Mean y

Predict

Residuals

A good fit leaves residuals scattered randomly around zero. A pattern in this column means the model has the wrong shape.

xy observedy predictedResidual
Instructions

How to use this calculator

Step by step

  1. Put your data in the box, one pair per line: the x value, then the y value, separated by a space, comma or tab. Two spreadsheet columns paste in directly.
  2. Every model that can legally be fitted to your data is listed, sorted by R² — highest first. Click any row to make it the active model.
  3. The equation of the active fit appears in the big panel, with R², the correlation and the standard error underneath.
  4. Tick Show residual lines to see the vertical gap between each point and the fitted curve. That is exactly what least squares is minimising.
  5. Type an x into the Predict box to run it through the model. The note underneath warns you when that x falls outside your data.
  6. Read the residual table at the bottom. Residuals should look random; a smooth pattern in them is the clearest sign the model has the wrong shape.

Good to know

  • A high R² is not proof of anything. It measures how well the model describes the data you have, not whether the relationship is real or causal.
  • Exponential, logarithmic and power models cannot be fitted to non-positive values — those models simply do not appear in the list when your data rules them out.
  • Beware of raising the polynomial degree until R² reaches 1. Any n points can be fitted exactly by a polynomial of degree n − 1, and that curve predicts nothing.
  • Extrapolation is the most common way a regression goes wrong. Inside the range of your data the fit is interpolation; outside it, you are trusting a shape you never observed.
  • The standard error of estimate is roughly the typical size of a residual — a more concrete measure of accuracy than R² for judging predictions.
  • Force the line through the origin only when the physics demands it (zero input must give zero output). It removes a parameter and usually lowers R².

The maths behind it

  • Least squares line b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², a = ȳ − b x̄ The slope and intercept that minimise the sum of squared residuals.
  • R² = 1 − SSres ÷ SStot The share of the variation in y that the model accounts for.
  • Correlation r = ±√R² Meaningful for a straight-line fit only; the sign follows the slope.
  • Standard error of estimate Sₑ = √( SSres ÷ (n − p) ) p is the number of fitted parameters.
  • Exponential linearised y = a·e^(bx) ⇔ ln y = ln a + bx Why the exponential fit needs strictly positive y values.
  • Power linearised y = a·x^b ⇔ ln y = ln a + b·ln x Both x and y must be positive.
Which model should I pick?

Start with the one your subject expects — physics and biology usually suggest the shape before the data does. If nothing suggests a shape, prefer the simplest model whose R² is close to the best, and check the residuals for a pattern. A model that wins on R² but leaves a curved residual plot is still the wrong shape.

Why is the exponential fit not the best even though my data is clearly exponential?

Because it is fitted by taking logs, which minimises error on the log scale rather than the original one. That gives small y values more influence than a direct nonlinear fit would. It is the standard method and it is what a graphing calculator does too, but on data spanning several orders of magnitude the difference is visible.

What does a negative R² mean?

That the model fits worse than a flat line at the mean. It can happen for a transformed fit forced onto data with the wrong shape. If you see it, the model does not belong on that data.

How many points do I need?

Two will produce a line, but it tells you nothing. For a straight-line fit worth quoting, aim for at least eight to ten points, and more if the scatter is large. A polynomial of degree d needs comfortably more than d + 1 points before its coefficients mean anything.