# Derivative of a summation w.r.t. inside term

My question is close to this one except for one term. More specifically:

$$\frac{1}{m}\sum_{i = 1}^m (x_i - \mu)^2$$

If I wanted to find the derivative of this entire term w.r.t. $$x_i - \mu$$, how would I go about that? Is this even possible?

Edit

I've tried the derivation but I'm not sure if this is correct. I also left out an important detail that in this context $$\mu = \frac{1}{m}\sum_{i = 1}^m x_i$$ (i.e. the mean of $$x$$'s).

\begin{align} \frac{\partial \sum}{\partial (x_i - \mu)} (\frac{1}{m}\sum_{i = 1}^m(x_i - \mu)^2) & = \frac{\partial \sum}{\partial (x_i - \mu)} \frac{1}{m}((x_1 - \mu)^2 + \cdots + (x_m - \mu)^2) \\ & = \frac{1}{m}(2(x_1 - \mu) + \cdots + 2(x_m - \mu)) \\ & = \frac{2}{m}( (x_1 + \cdots + x_m) - 2m\mu) \\ & = 2 \times \frac{1}{m}\sum_{i = 1}^m x_i - 4\mu \\ & = 2\mu - 4\mu \\ & = -2\mu \end{align}

I'm not entirely sure if this derivation is correct...

• Rename your variables (for example $$t_i = x_i - \mu$$). So yes, you can differentiate with respect to $$t_i$$.
• Result $$\frac{2}{m} \left( x_i - \mu \right)$$