Linear regression

Linear regression: calculate a transparent estimate from the values and assumptions you provide.

Linear regression: calculate a transparent estimate from the values and assumptions you provide.

Your inputs stay in your browser. Displayed results are rounded to a maximum of 12 significant digits.

Method and assumptions

Method version 1.0.0 · Updated

Calculate

Formula: Least squares: slope = covariance(X,Y) / variance(X)

Linear regression: calculate a transparent estimate from the values and assumptions you provide.

xValues
X values separated by ;
yValues
Y values separated by ;

Deterministic floating-point calculation. The displayed result is rounded to a maximum of 12 significant digits.

Calculate with code

These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.

JavaScript
const slope = 2, intercept = 0; const predict = (x) => slope * x + intercept; // x=4 → 8