Partial derivative of sample standard deviation w.r.t individual data points

600 Views Asked by At

I would like to derive the partial derivative $\delta f \,/ \, \delta x_j $ for

$$ f(x_1,x_2,...,x_{j-1},x_j,x_{j+1},...,x_n)=\sqrt{\frac{\sum_{i=1}^n (x_i - \bar{x})^2}{n-1}} $$

which is the partial derivative of the sample standard deviation with respect to a specific data point $x_j$.

Using the chain rule of differentiation:

$$ \frac{\delta f}{\delta x_j}=\frac{\delta f}{\delta u}\frac{\delta u}{\delta x_j} $$

$$ u=\frac{\sum_{i=1}^n (x_i - \bar{x})^2}{n-1} $$

$$ \frac{\delta f}{\delta u}=\frac{1}{2\sqrt{u}} $$ $$ \frac{\delta u}{\delta x_j}=\frac{2}{n-1} \Bigl( \frac{x_j}{n}-\bar{x} \Bigr) $$ $$ \frac{\delta f}{\delta x_j} = \frac{\frac{1}{n-1}(\frac{x_j}{n}-\bar{x})}{s} $$

where $s$ is the sample standard deviation itself.

However, I think this is incorrect. In a simple example: $x_1=1, x_2=2, x_3=3$, then my estimate of $\delta f \,/ \, \delta x_j $ is always negative. It seems to me that $\delta f \,/ \, \delta x_3 $ should be positive.

Does anyone know where I might have messed up?

In the working out for $\delta u / \delta x_j$ (below) I tried to separate the $x_j$ and non-$x_j$ terms before differentiating with respect to $x_j$.

Can anyone see what went wrong? I can't see any mistakes.

EDIT: Working out for $\delta u / \delta x_j$: $$ u=\frac{\sum_{i=1}^n (x_i - \bar{x})^2}{n-1} \\ =\frac{\sum_{i=1}^{n}\Bigl( x_i - \frac{x_j}{n} - (\frac{x_1+x_2+...+x_{j-1}+x_{j+1}+...x_n}{n})\Bigr)^2}{n-1} \\ =\frac{\sum_{i=1}^n \Bigl((x_i-\frac{x_j}{n}-C)(x_i-\frac{x_j}{n}-C)\Bigr)}{n-1} \\ =\frac{\sum_{i=1}^n \Bigl(x_i^2 - 2\frac{x_i x_j}{n} - 2Cx_i + 2C\frac{x_j}{n} + \frac{x_j^2}{n^2} + C^2\Bigr)}{n-1}\\ =\frac{x_j^2-2Cx_j + n2C\frac{x_j}{n}+n\frac{x_j^2}{n^2}-2x_j \bar{x} + Z}{n-1} \\ \Bigl[note: \sum_{i=0}^{n}-2\frac{x_i x_j}{n} = -2x_j \sum_{i=0}^{n}\frac{x_i}{n}=-2x_j\bar{x} \Bigr]\\ [C \text{ and } Z \text{ are supposed to be all the non-}x_j\text{ terms]}\\ =\frac{x_j^2+\frac{x_j^2}{n}-2x_j \bar{x}+Z}{n-1}\\ \frac{\delta u}{\delta x_j} = \frac{\Bigl( 2x_j + \frac{2}{n}x_j - 2(\bar{x}+x_j )\Bigr)}{n-1}\\ =\frac{2}{n-1}\Bigl(x_j + \frac{x_j}{n} - \bar{x} - x_j \Bigr)\\ =\frac{2}{n-1}\Bigl( \frac{x_j}{n}-\bar{x} \Bigr) $$