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. Enter aligned lists or one x,y pair per line. The normal-equation matrix and right-hand side are shown explicitly with coefficient order [intercept, slope], while the numerical fit uses centered/scaled observations rather than directly inverting that matrix.
slope = Σ(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.
Reference: NIST: least-squares linear fitting (opens in a new tab) ↗
Keep each x paired with its measured y
The Spearman rank correlation calculator compares ranks rather than fitting a straight line to raw values. The forecast error calculator compares actual observations with supplied predictions instead of estimating a regression line.
Least-squares regression with an intercept chooses a line that minimizes the sum of squared vertical residuals. Each x must stay paired with its corresponding y. Sorting the lists independently can destroy that relationship even though the two lists still contain the same numbers.
For points (1,3), (2,5) and (3,7), the fitted line is y=2x+1 and all residuals are zero. A nonzero residual is observed y minus fitted y. The table keeps those quantities separate rather than presenting only a line equation without its measurement-level fit.
When both coordinates have measurement error, the Deming regression with entered measurement error ratio calculator uses an entered error-variance ratio instead of assuming a fixed predictor. For an entered analytical standard set, the Absorbance standard curve inverse concentration calculator fits response against concentration and then performs an explicitly flagged inverse estimate.
A fitted relationship does not establish a cause
Pearson correlation and R² summarize particular aspects of this fitted relationship; they do not prove that changing x would cause a change in y. A constant x list cannot determine a unique slope, while a constant y list has an undefined correlation denominator even though a horizontal fitted line can exist.
A requested x outside the observed range is extrapolation and is labelled separately. The Spearman rank correlation calculator assesses monotonic rank association using a different calculation. Neither method removes outliers or supplies a causal experiment merely because a correlation coefficient is available.
A few questions, answered
Must the x and y lists have the same length?
Yes. Every observation needs one matched value in each list.
Why reject a constant x list?
There is no variation in x from which to determine a unique slope.
Does a perfect R² guarantee future predictions?
No. It describes the observed fit under this model, not a guarantee about new data.