The slope mm and the intercept qq of the regression line are computed directly from the data with the following formulae.

Property — Least-squares formulae

m=nxiyi(xi) ⁣(yi)nxi2(xi) ⁣2,q=yˉmxˉm = \frac{n\,\displaystyle\sum x_i y_i - \biggl(\sum x_i\biggr)\!\biggl(\sum y_i\biggr)}{n\,\displaystyle\sum x_i^2 - \biggl(\sum x_i\biggr)^{\!2}}, \qquad q = \bar{y} - m\,\bar{x} where xˉ=1nxi\bar{x}=\dfrac{1}{n}\sum x_i and yˉ=1nyi\bar{y}=\dfrac{1}{n}\sum y_i are the means.

The line always passes through the point (xˉ,yˉ)(\bar{x},\,\bar{y}) (centroid of the data).

Topics: Radicals
Concepts: Least squares · Linear regression
Skills: Analytic geometry · Using formulae