Skip to content
CalculatorAtlas

Linear Regression Calculator

Tested

Least-squares line y = a + bx through paired data.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

Results

Enter your values and press Calculate. Results appear here.

  • • Result

Quick answer

Least-squares line y = a + bx through paired data. Enter x values and y values and the linear regression calculator returns regression line, slope and intercept.

Related tools: Least Squares Regression Calculator: Fit the least-squares regression line to paired data and read off the slope, intercept and a prediction. Multiple Linear Regression Calculator: Least-squares coefficients and R² for up to three predictors. Correlation Coefficient Calculator: Pearson correlation of two variables.

This page covers the same calculation as the least squares regression page; the two give identical results.

How to use the Linear Regression Calculator

  1. Type x values, for example 1, 2, 3, 4, 5.
  2. Type y values, for example 2, 4, 5, 4, 5.
  3. Optionally, enter predict y at x.
  4. Press Calculate to see the result, and use Reset to start again.
Inputs of the Linear Regression Calculator
InputWhat to enterAllowed values
x valuesText, such as 1, 2, 3, 4, 5—
y valuesText, such as 2, 4, 5, 4, 5—
Predict y at x (optional)A number—

Formula and method

Formula

b = Sxy ÷ Sxx; a = ȳ − b·x̄; r² = Sxy² ÷ (Sxx·Syy)

IEEE-754 double precision; shown to at most 6 decimal places.

Ordinary least squares for one predictor.

Worked examples

This example is verified: each one is an automated test case that the live calculator must reproduce exactly.

Example 1

Inputs: x values = 1,2,3,4,5; y values = 2,4,5,4,5; Predict y at x = 6.

Results of example 1
ResultValue
Regression liney = 2.2 + 0.6x
Slope0.6
Intercept2.2
r²0.6
Predicted y5.8

The first line is the headline result (regression line). Below it the linear Regression Calculator lists slope, intercept, r² and predicted y, which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.

How the result changes with predict y at x

Holding every other input at the first worked example, this table changes only predict y at x. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.

How the result changes with predict y at x
Predict y at xRegression lineSlopeIntercept
3y = 2.2 + 0.6x0.62.2
6y = 2.2 + 0.6x0.62.2
12y = 2.2 + 0.6x0.62.2
24y = 2.2 + 0.6x0.62.2

What happens with invalid input

These messages are produced by the calculator itself, so you know what to fix.

  • x values: entering "2,2,2" shows "x values must not all be equal." beside that field and no result.

Choosing between the Linear Regression Calculator and similar calculators

Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.

Choosing between the Linear Regression Calculator and similar calculators
CalculatorYou enterIt returns
[Least Squares Regression Calculator](/statistics/least-squares-regression/)x values and y valuesRegression line
[Multiple Linear Regression Calculator](/statistics/multiple-regression-calculator/)response values and predictor 1Coefficients (intercept, b₁, b₂ …)
[Correlation Coefficient Calculator](/statistics/correlation-coefficient-calculator/)x values and y valuesCorrelation r
[Covariance Calculator](/statistics/covariance-calculator/)x values and y valuesSample covariance
[R-Squared Calculator](/statistics/r-squared-calculator/)x values and y valuesR²

Background: regression and correlation

Least squares chooses the line that minimises the sum of the squared vertical distances from the points. The slope is the sum of the cross-products of the deviations divided by the sum of the squared x deviations, and the intercept is the mean of y minus the slope times the mean of x.

For simple regression R² is the square of the correlation coefficient r, the share of the variation in y that the line explains. R² has no sign, so the sign of the slope tells you whether the relationship rises or falls. A strong fit does not prove one variable causes the other.

Assumptions and limitations

  • x must vary

If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for x values to confirm this.

Frequently asked questions

What does the Linear Regression Calculator calculate?

Least-squares line y = a + bx through paired data. It returns Regression line, Slope, Intercept, r² and Predicted y.

What formula does the Linear Regression Calculator use?

b = Sxy ÷ Sxx; a = ȳ − b·x̄; r² = Sxy² ÷ (Sxx·Syy). Ordinary least squares for one predictor.

What do I need to enter in the linear Regression Calculator?

You enter x values and y values. Optional: Predict y at x.

How is the result rounded or limited?

IEEE-754 double precision; shown to at most 6 decimal places. x must vary.

What is an example of a linear Regression result?

With x values 1,2,3,4,5, y values 2,4,5,4,5 and predict y at x 6, the regression line is y = 2.2 + 0.6x.

Sources

  • NIST/SEMATECH e-Handbook of Statistical Methods (itl.nist.gov/div898/handbook)
  • Standard textbook definitions (e.g. Moore, McCabe & Craig, Introduction to the Practice of Statistics)

Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.