Statistics & probability

Simple linear regression calculator

Fit a straight line to paired data and inspect correlation, residuals and a prediction.

Your numbers

Up to 1,000 finite numbers separated by commas, spaces or semicolons. No missing-value markers. Values must be within ±1 trillion.
Up to 1,000 finite numbers separated by commas, spaces or semicolons. No missing-value markers. Values must be within ±1 trillion.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your numbers and select Calculate.

Behind the numbers

How this calculation works

Fit ordinary unweighted least squares with an intercept, preserving the entered pairing. The result includes fitted values and vertical residuals, Pearson correlation, R² and an input-specific prediction. A prediction outside the observed x range is labeled extrapolation.

THE FORMULAslope = Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²; intercept = ȳ − slope × x̄

A worked example

For x = 1,2,3,4 and y = 2,4,5,4, the slope is 0.7, intercept 2 and prediction at x = 2.5 is 3.75. Residual sum of squares is 2.3.

Good to know

Unweighted descriptive calculations for up to 1,000 observations within ±1 trillion. Floating-point arithmetic and rounded display are used. No missing values are silently removed, no population distribution is inferred, and no confidence intervals are supplied.

A fitted line summarizes paired observations

The first x entry belongs to the first y entry, and so on. Sorting the two lists separately would destroy their pairing and change the question. The tool preserves their entered order and displays every observed pair beside its fitted value.

Ordinary least squares with an intercept minimizes the sum of squared vertical residuals. It does not minimize horizontal errors or perpendicular distances to the line. The fitted line passes through the pair of sample means under this model.

For x = 1,2,3,4 and y = 2,4,5,4, the fitted line is y = 2 + 0.7x. At x = 2.5 its prediction is 3.75. The residuals are −0.7, 0.6, 0.9 and −0.8, with squared sum 2.3.

Separate interpolation, extrapolation and explanation

A prediction inside the observed x range is interpolation within the fitted model. Outside that range it is extrapolation. Linear interpolation through two selected points is a different task from fitting one line to several noisy observations.

Pearson correlation measures linear association. R² summarizes the fitted fraction of variation around the sample mean in this intercept model. Neither value proves causation or rules out a curved pattern, confounding or influential observations.

A constant x list cannot determine a unique slope. A constant y list has a zero-slope fit but undefined correlation and R² under the convention used here. Two distinct-x pairs define a line, but residual standard error requires more than two pairs. No confidence or prediction interval is inferred from these descriptive outputs.

A few questions, answered

Does a large R² prove the line is suitable?

No. Inspect the residuals and the context, including dependence, outliers and possible nonlinear patterns. A descriptive coefficient is not a model validation test.

Are the inputs weighted?

No. Each pair receives equal weight. A weighted average of observations is a different operation from weighted least-squares fitting.

Can I infer a causal effect from the slope?

No. The fit describes association in the supplied pairs. Causal interpretation needs a suitable study design and additional assumptions.

Find your calculator

Start typing to explore the library.