Linear Regression Calculator

Fit a best-fit line through up to four points.

Best-fit line y = 1.9x + 0
Slope 1.9
Intercept 0
0.9627

Formula: least squares: slope = Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)²

Step-by-step with your numbers:
1. Values used:
2. x₁ = 1
3. y₁ = 2
4. x₂ = 2
5. y₂ = 4
6. x₃ = 3
7. y₃ = 5
8. x₄ = 4
9. y₄ = 8
10.
11. Best-fit line = y = 1.9x + 0
12. Slope = 1.9
13. Intercept = 0
14. R² = 0.9627
Did we solve your problem today?

Find the least-squares line of best fit through your data points.

The math behind it

slope = Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)²; intercept = ȳ − slope×x̄; R² measures fit quality.

Worked example

Sample points → y ≈ 1.9x + 0 (R² ≈ 0.92).

FAQ

R²?

The fraction of variance in y explained by x (0–1).