Loona Calculators
Loona Calculators › Maths › Linear Regression Calculator

📈 Linear Regression Calculator

Paste paired x,y data to fit the least-squares line of best fit: slope, intercept, correlation, the fitted equation, predictions for any x — and a scatter plot with your points and the line drawn through them.

Quick answer: Least squares: slope b = Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)², intercept a = ȳ − b·x̄. For x = 1..5, y = 2,4,5,4,5: slope = 6 ÷ 10 = 0.6, intercept = 4 − 0.6×3 = 2.2, so the line is y = 2.2 + 0.6x.

How to use the Linear Regression Calculator

  1. Paste matching x and y lists (at least 3 pairs).
  2. Press Fit the line to see the equation, r and r², plus the scatter plot.
  3. Enter any x to read the model's predicted y.
Example: For the study-hours data (x = 1–5, y = 2,4,5,4,5) the line y = 2.2 + 0.6x predicts a score of 2.2 + 0.6×6 = 5.8 at x = 6 — an extrapolation beyond the data, so treat it cautiously.

Frequently Asked Questions

What does 'least squares' mean?

The line is chosen to minimise the sum of the squared vertical gaps (residuals) between the points and the line. Squaring punishes big misses heavily, which is why outliers can drag the line.

Slope and intercept in plain words?

The slope is how much y changes, on average, when x rises by 1. The intercept is the model's y when x = 0 — meaningful only if x = 0 is inside or near your data's range.

Is predicting outside the data range safe?

That is extrapolation, and it is risky: relationships often bend beyond the observed range. The calculator will compute it, but the further from your x-range, the less the line deserves trust.

How is this related to the Correlation Calculator?

They share the same sums: r is the standardised slope. Regression adds the actual line (in y-units per x-unit) and predictions, which correlation alone cannot give.

Related Calculators

%

Percentage Calculator

Maths

📊

Statistics Calculator

Maths

½

Fraction Calculator

Maths

🧮

Equation Solver

Maths

🔬

Scientific Calculator

Maths

📐

Average Calculator

Maths

🔔

Z-Score Calculator

Maths

🎲

Probability Calculator

Maths

🔗

Correlation Calculator

Maths

📈

Graphing Calculator

Maths

How it works — the formula

Slope b = Sxy ÷ Sxx where Sxy = Σ(x−x̄)(y−ȳ) and Sxx = Σ(x−x̄)². Intercept a = ȳ − b·x̄ — which guarantees the line always passes through the centre of mass of the data, (x̄, ȳ). Prediction: ŷ = a + b·x. Also reported: r, r², and the residual standard error.

Worked example

Inputs: x = [1,2,3,4,5], y = [2,4,5,4,5].

Steps: x̄ = 3, ȳ = 4, Sxy = 6 (from the correlation working), Sxx = 10. Slope = 6 ÷ 10 = 0.6. Intercept = 4 − 0.6 × 3 = 2.2. Prediction at x = 6: 2.2 + 0.6 × 6 = 5.8.

Result: Line y = 2.2 + 0.6x, r = 0.775, r² = 0.600.

Embed this calculator on your website — free

Add this calculator to your own website or blog — it is completely free, needs no sign-up, and always shows the latest version. Copy the code below and paste it into your page where you want the calculator to appear. Keeping the small “Powered by Loona Automation” credit line under the embed helps keep this tool free — but you are free to style or remove it; the tool works either way.