Least squares is a form of approximation, used to make a prediction based on experimental data. 

Given a set of points (x_1, y_1) (x_2, y_2)...(x_n, y_n), and the deviation from the points d=y_i - (ax_i + b) minimize D=\sum_{i=1}^n (y_i - (ax_i+b))^2.

Finding the minimum involves talking a look a the derivates.

  • \frac{\delta D}{\delta a}=\sum_{i=1}^n 2 (y_i - (ax_i + b)) (-x_i)
  • \frac{\delta D}{\delta b}=\sum_{i=1}^n 2 (y_i - (ax_i + b)) (-1)

Removing unnecessary 2 constant (solving to approach 0), and simplifying:

  • \frac{\delta D}{\delta a}=\sum_{i=1}^n (y_i - (ax_i + b)) (-x_i) = \sum (a x_i^2 + x_i b + - x_i y_i)
  • \frac{\delta D}{\delta b}=\sum_{i=1}^n (y_i - (ax_i + b)) (-1) = \sum (a x_i + b - y_i)

This can be re-written as a 2x2 linear system:

  • a \sum x_i^2  + b \sum x_i = \sum x_i y_i
  • a \sum x_i + b n = \sum y

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.