Data & AnalyticsLive🔒 Private

Linear Regression Two Points

Calculate linear regression slope and intercept from two points. Free online regression tool. No signup, 100% private, browser-based.

Linear Regression Two Points

Equation

y=2x

How it works

A linear regression through two points is the simplest possible model fit: given exactly two (x, y) data points, there is exactly one line passing through both. This is the equation-of-a-line problem familiar from high school mathematics, but framed in the context of regression and prediction.

**Slope and intercept calculation** Slope (m) = (y2 − y1) / (x2 − x1) — rise over run. Intercept (b) = y1 − m × x1. The resulting equation y = mx + b can be used to predict y for any x value. This is an exact fit (residuals are zero) because a line is defined by exactly two points — ordinary least squares with two data points has zero degrees of freedom.

**Why two-point regression is useful** Interpolation between two known values: temperature conversion formulas, unit conversion factors, cost estimations with two reference points. Linear extrapolation: extending a trend line beyond observed data (with appropriate caution — linear extrapolation breaks down quickly outside the observed range). Price escalation: given costs at two points in time, estimate future costs. Calibration curves: given two calibration standards, fit a linear response curve for instrument measurement.

**Limitations** Two points define a line exactly but provide no information about how well a linear model fits the underlying relationship. With more data points, use ordinary least squares to assess goodness of fit (R², residual plots). Extrapolation beyond the observed range introduces uncertainty that grows linearly with distance from the known points.

Frequently Asked Questions

What is the equation of a line through two points?
Given points (x1, y1) and (x2, y2): slope m = (y2 − y1) / (x2 − x1). Intercept b = y1 − m × x1. Line equation: y = mx + b. To predict y for a new x: substitute into the equation. Example: points (2, 5) and (6, 13). m = (13−5)/(6−2) = 8/4 = 2. b = 5 − 2×2 = 1. Equation: y = 2x + 1. For x = 4: y = 9. Note: this is an exact fit (zero residuals) — not an estimate of true underlying relationship.
When is linear extrapolation dangerous?
Linear extrapolation assumes the linear relationship observed between the two known points continues indefinitely. This fails when: the underlying relationship is nonlinear (curves away from the linear trend), the relationship has physical limits (temperature cannot exceed absolute zero), or regime changes occur outside the observed range (a drug's effect peaks and then declines rather than increasing linearly). Always state extrapolation assumptions explicitly and bound the valid range.
How is this different from ordinary least squares regression?
Two-point regression passes a line exactly through both points — it is not a statistical fit, and there are no residuals. Ordinary least squares (OLS) fits a line to n > 2 points by minimizing the sum of squared residuals. OLS produces slope and intercept estimates with associated standard errors, p-values, and R², which quantify how well the linear model fits. Two-point regression gives you one possible line; OLS gives you the best-fit line through all available data.
What real-world calibration problems use two-point linear regression?
Temperature sensor calibration: measure sensor output at two known temperatures (e.g., ice water = 0°C and boiling water = 100°C), fit a line, use it to convert future readings. pH meter calibration: use two buffer solutions (pH 4 and pH 7). Flow meter calibration: measure output at two known flow rates from a reference standard. Cost estimation: if a project of size 10 costs $50K and size 20 costs $90K, the linear model predicts size 15 costs $70K.