Linear Regression Calculator

Line of best fit, slope, intercept and R² with a scatter plot.

Line of best fit
y = 1.99x + 0.05
Slope
1.99
Intercept
0.05
r
0.998652
0.997305
Points
5
Show the working
  1. 1Slope = Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)² = 1.99
  2. 2Intercept = ȳ − slope × x̄ = 0.05
  3. 3r² = 0.9973 of the variance is explained by the line
Formula
y = mx + b (least squares)

How it works

Fits the straight line that minimises the squared vertical distance to your points, and reports how well it fits (r²).

Example

The near-linear data above fits y ≈ 2.00x + 0.02 with r² ≈ 0.999.

About the Linear Regression Calculator

Line of best fit, slope, intercept and R² with a scatter plot. It sits in the Statistics section of NWS Calc, a free collection of calculators that run entirely in your browser. There is no signup, no paywall and no tracking — open the page, enter your numbers, get an answer.

Frequently asked questions

Is the Linear Regression Calculator free to use?
Yes. Every calculator on NWS Calc is completely free, with no signup, no usage limits and no ads.
Does my data leave my device?
No. The Linear Regression Calculator runs entirely in your browser using JavaScript. Nothing you type is uploaded, logged or stored on a server.
Can I use the Linear Regression Calculator on my phone?
Yes. The page is fully responsive and works in any modern mobile or desktop browser — there is nothing to install.
What else is in Statistics?
Mean, deviation, regression, probability and distributions. You can browse the full Statistics category for related calculators.

Related calculators