Is there anyway I can pull x out of this summation to solve for it?
$$ 0 = \frac{-2}{N} \sum_i^N a_i(b_i - (xa_i))$$
EDIT: Thanks for all the quick comments guys.
I am confused by a certain step everyone seems to be taking.
$$ -\sum_i^N xa_i^2 = -x\sum_i^N a_i^2 $$
Can someone explain or link me to somewhere that explains how this is true.
$\endgroup$ 14 Answers
$\begingroup$given
$$0 = \dfrac{-2}{N} \sum_i^N a_i(b_i - (xa_i))$$
$0=\dfrac{-2}{N} \sum_i^N(a_ib_i-xa_i^2)$
$0=\dfrac{-2}{N} \big (\sum_i^Na_ib_i-\sum_i^Nxa_i^2)$
$0=\dfrac{-2}{N} \big (\sum_i^Na_ib_i-x\sum_i^Na_i^2)$
EDIT: Here, we treat $x$ as a constant. Hence it can be 'pulled' out of the summation
For example :
$2+4+6=12$
$2(1+2+3)=12$
here, $2$ being a constant can be 'pulled' out from the summation
$\endgroup$ 4 $\begingroup$Hint: The sum is $\sum_{i=1}^N a_ib_i-x\sum_{i=1}^N a_i^2$.
$\endgroup$ $\begingroup$You can, with a bit of work. We have $$ \sum_i^Na_i(b_i-xa_i) = \sum_i^N(a_ib_i-xa_i^2) = \sum_i^Na_ib_i-x\sum_i^N a_i^2 $$ and from there it's easy.
$\endgroup$ $\begingroup$This is not an answer but a question:
This looks like the summations involved when you are fitting a straight line through the origin to a set of data points by least squares. Is that what you are trying to do?
If you are learning about least squares and other types of fitting, you will be doing a $lot$ of summations, and you will need to get comfortable with them.
$\endgroup$