Start with the definition of the sum of squared errors:

To find the value of b that minimizes this, we take the derivative and set the result to 0:

Noting that b has no dependence on i, the sum on the right reduces to n*b and we have:

That last equation is the mean of y. I thought this was kind of cool even though it's really obvious when doing the math.

I noted at the beginning that I noticed this at work. Specifically, it was doing a linear fit where the slope ended up being very close zero. If we take the derivation of that (copied from wikipedia):

and the slope ends up being zero, you get the same equations I walked through above. A simple plot showing it with numbers:

The best fit runs straight through the mean. Neat.

## 0 comments:

## Post a Comment