As part of a derivation, I have the following derivation. I understand the whole thing, but I do not understand how the author went from the first line here, to the second line. Can someone please elucidate how they did that?

He basically seems to have "opened up" the $\mathbf{x} - \mathbf{x}_i$ term, but I am not clear how that translates to what is written in the second line.

Context: The formula comes from a derivation here


enter image description here


1 Answer 1


Edit: Let's try this again. We have \begin{align*} \nabla f(\mathbf{x})&=\frac{2c}{nh^{d+2}}\sum_{i=1}^n(\mathbf{x_i}-\mathbf{x})g(\cdot)\\ &=\frac{2c}{nh^{d+2}}\sum_{i=1}^n\Big(\mathbf{x_i}g(\cdot)-\mathbf{x}g(\cdot)\Big)\;\;\text{distributing g}\\ &=\frac{2c}{nh^{d+2}}\left(\sum_{i=1}^n\mathbf{x_i}g(\cdot)-\sum_{i=1}^n\mathbf{x}g(\cdot)\right)\;\;\text{ break into two sums}\\ &=\frac{2c}{nh^{d+2}}\left(\sum_{i=1}^n\mathbf{x_i}g(\cdot)-\mathbf{x}\sum_{i=1}^ng(\cdot)\right)\;\;\text{pull out x}\\ &=\frac{2c}{nh^{d+2}}\left(\sum_{i=1}^ng(\cdot)\right)\left(\frac{\sum_{i=1}^n\mathbf{x_i}g(\cdot)}{\sum_{i=1}^ng(\cdot)}-\mathbf{x}\right)\;\;\text{ factor out the sum of just g} \end{align*}

  • $\begingroup$ @Spacey I can't say much more about this without some more context (and even with more context, I don't know much about gaussian functions). All I can say is that the author probably moved the $\mathbf{x_i}$ inside the summation because that worked in the current derivation that they were working on. Since $\mathbf{x_i}$ does not depend on the index of summation it is perfectly fine to put it wherever works best for the proof, just as I can write $5\cdot(3+x)=(5\cdot3+5\cdot x)$. $\endgroup$
    – TomGrubb
    Commented May 17, 2017 at 15:53
  • $\begingroup$ Wait...but $x_i$ does depend on the index of summation... $\endgroup$
    – Spacey
    Commented May 17, 2017 at 16:00
  • $\begingroup$ @Spacey You're right, I did not look closely enough at the second sum. I will delete this, but before I do so, would you mind posting some more context for the problem? It is hard to read the author's intent just by looking at two equalities $\endgroup$
    – TomGrubb
    Commented May 17, 2017 at 16:03
  • $\begingroup$ Thanks - and I just edited the question with a link to the context. $\endgroup$
    – Spacey
    Commented May 17, 2017 at 16:04
  • $\begingroup$ @Spacey It should be fixed now I hope. Let me know if you need any more clarification $\endgroup$
    – TomGrubb
    Commented May 17, 2017 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .