All courses › Statistics and Risk Analysis › Least squares

Least squares

Regression finds the line that best fits a scatter of points. The least squares method chooses the slope and intercept so that the sum of the squared deviations from the line is as small as possible. The line always passes through the point of the means.

y^=a+bx\hat y = a + b xregression line
b=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2b = \frac{\sum (x_i - \bar x)(y_i - \bar y)}{\sum (x_i - \bar x)^2}slope
a=yˉ−bxˉa = \bar y - b\bar xintercept

Symbols

bbslope
aaintercept
xˉ, yˉ\bar x,\ \bar ymeans

Example

The points (1, 2), (2, 4), (3, 5):

xˉ=2\bar x = 2, b=3/2=1.5b = 3/2 = 1.5 and a=11/3−3≈0.67a = 11/3 - 3 \approx 0.67.

Only use the line within the range of your data. Outside it the relationship may be completely different.
Practise regression and correlation for free →

← MTBF, MTTR and availability · Correlation coefficient →

Part of Statistics and Risk Analysis: Regression and correlation.