Skip to content
Statistics

Linear Regression Calculator

Fit a straight line through up to 4 paired X and Y values and predict Y for any given X using ordinary least squares.

Only the first this-many X/Y pairs below are used (2 to 4 pairs).

Your results

Regression equationy = 1.9x + 0
Predicted y at x = 59.5
Slope1.9
Intercept0

Calculation breakdown

Slope
m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)²
Intercept
b = ȳ − m × x̄
Prediction
ŷ = m×x + b

Worked example

Fitting a line through (1,2), (2,4), (3,5) and (4,8) gives roughly y = 2x − 0.5, predicting y ≈ 9.5 for x = 5.

Assumptions

  • Fits a simple ordinary least-squares straight line; it does not capture curved or non-linear relationships.
  • With only 2–4 points, the fitted line is illustrative and can be sensitive to a single unusual value.

How this calculator works

Enter up to 4 paired X and Y values and a value of X to predict. The calculator fits an ordinary least-squares straight line through the data and returns the slope, intercept and predicted Y value.

Frequently asked questions

What do the slope and intercept mean?

The slope shows how much Y changes for each one-unit increase in X, and the intercept is the predicted Y value when X is zero.

Can I trust predictions far outside my data range?

No, extrapolating well beyond your original X values is unreliable, since the true relationship may not stay linear outside that range.

What if my data isn't linear?

A straight-line fit will poorly describe curved relationships; check a scatter plot first to see if a linear model is appropriate.

Related calculators

← Back to all calculators