Linear Regression

Enter points as x, y pairs.

Use this tool

Result

The result appears in this panel after you run the tool.

About this tool

The fit is ordinary least squares for one line.

Fewer than two distinct x values is rejected.

How to use it

  1. Open this page and provide the input it asks for.
  2. Set the options that are visible, then use Fit line.
  3. Read the result in the panel. Copy it or download it when a file is offered. The input stays in this browser.

Limitations

Ordinary least squares for one line

Slope, intercept, and r

Each point is an x and a y, one pair per line or separated by semicolons. At least two points are required. Let n be the count. Let sumX, sumY, sumXY, sumXX, and sumYY be the usual totals. The denominator is n × sumXX − (sumX)². The slope is (n × sumXY − sumX × sumY) / that denominator. The intercept is (sumY − slope × sumX) / n. The correlation r divides the same numerator by the square root of (n × sumXX − (sumX)²) × (n × sumYY − (sumY)²), unless that square root is zero, in which case r is reported as 0. The panel prints slope, intercept, and r as raw decimals, and draws the line through the points.

Three points on a gentle rise

The points (1, 2), (2, 3), and (3, 5) give n = 3, sumX = 6, sumY = 10, sumXY = 23, and sumXX = 14. The denominator is 3×14 − 36 = 6. The slope numerator is 3×23 − 6×10 = 9, so the slope is 1.5. The intercept is (10 − 1.5×6) / 3 = 1/3, which prints as a binary expansion beginning 0.3333333333333333. The correlation prints as a raw value beginning 0.9819805060619657. The fitted line is y = 1.5 x + 1/3.

Flat x, flat y, and a single point

If every x is the same, the denominator is zero and the slope is refused as undefined. Two copies of one point are that case, not a successful horizontal fit. A single point is refused earlier, because two points are the minimum. If the x values vary but every y is the same, the slope and intercept describe a horizontal line, and r is forced to 0 because the y-spread under the square root vanishes. That zero is a stand-in, not a computed correlation, since the usual formula would divide by zero. The page does not report residuals, p-values, or a second regressor. The chart scales to the data and the fitted segment. It is an illustration of this line, not a general plotting tool.

Privacy

Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.