# How to differentiate a part of normal likelihood function

$e^{-1/2 \sum_{i=1}^n (x_i - \theta)^2}$ wrt to $\theta$? (Without log.)

-
First convince yourself (e.g. with a few examples) that the exponent is a quadratic function of $\theta$, of the form $a \theta^2 + b\theta + c$. Therefore the function you want to differentiate is of the form $e^{a \theta^2 + b\theta + c}$. Then (i) recall from Calculus how to differentiate such a function, (ii) determine $a, \, b, \, c$ from the other information given to you, that is, in terms of the $x_i$. – Hans Engler Oct 30 '12 at 14:20
The problem actually come from the chain rule. After diff. it will become $\sum (e^{x_j - \theta} e^{-1/2 \sum_{i \neq j} (x_i - \theta)^2})$ right? How to simplify it further? – RHS Oct 30 '12 at 14:27
What I want is reduce the above diff. to $\sum_{i=1}^n (x_i - \theta) = 0$. With ln this is obvious $d/d\theta \ln e^{-1/2 \sum (X_i - \theta)} = 0$. But how to find it without ln? – RHS Oct 30 '12 at 14:47
Oh I mean product rule above. – RHS Oct 30 '12 at 15:07

Well, if that helps you, using the chain rule:

$$\left(e^{-\frac{1}{2}\sum^{n}_{i=1}(x_{i}-\theta)^2}\right)^{\prime}=e^{-\frac{1}{2}\sum^{n}_{i=1}(x_{i}-\theta)^2}\cdot\left(-\frac{1}{2}\right)\sum^{n}_{i=1}(2\theta-2x_{i})=-e^{-\frac{1}{2}\sum^{n}_{i=1}(x_{i}-\theta)^2}\sum^{n}_{i=1}(\theta-x_{i})$$

EDIT

To respond to your comment - if want to equate this expression to $0$, we know that $\sum^n_{i=1}(\theta-x_{i})=0$ because the exponential function does not reach zero for any argument.

EDIT 2

To illustrate how the chain rule works, let $f(\theta)=-\frac{1}{2}(x_{i}-\theta)^2$ and $h(\theta)=e^{f(\theta)}$. The derivative of $h$ is thus equal to:

$$h^{\prime}(\theta)=h(\theta)\cdot f^{\prime}(\theta)$$

We know that $f=-\frac{1}{2}(x_{i}^{2}-2x_{i}\theta+\theta^{2})=-\frac{1}{2}x_{i}+x_{i}\theta-\frac{\theta^{2}}{2}$, hence $f^{\prime}(\theta)=x_{i}-\theta=-\frac{1}{2}(2\theta-2x_{i})$

Thus finally:

$$h^{\prime}(\theta)=h(\theta)\cdot f^{\prime}(\theta)=e^{-\frac{1}{2}(x_{i}-\theta)^2}\cdot -\frac{1}{2}(2\theta-2x_{i})=-e^{-\frac{1}{2}(x_{i}-\theta)^2}\cdot(\theta-x_{i})$$

-
Why the middle part of the diff. is true? – RHS Oct 30 '12 at 15:00
It's called the chain rule: $(f(g(x))^{\prime}=f^{\prime}(g(x))g^{\prime}(x)$ en.wikipedia.org/wiki/Chain_rule Do you see that now? – Johnny Westerling Oct 30 '12 at 15:03
And obviously, we have $(x_{i}^{2}-2\theta x_{i}+\theta^{2})^{\prime}=2\theta-2x_{i}$. – Johnny Westerling Oct 30 '12 at 15:05
When I $(d/d\theta) e^{-1/2(x_1 - \theta)^2} \cdot \cdots \cdot e^{-1/2 (x_n - \theta)^2}$. I will get $\sum e^{x_j - \theta} e^{-1/2 \sum_{i \neq j} (x_i - \theta)^2}$ which is a completely different form right? Why? – RHS Oct 30 '12 at 15:13
For every $i$, $(d/d\theta)e^{-1/2(x_{i}-\theta)^2}=e^{-1/2(x_{i}-\theta)^2}\cdot(-1/2)(2\theta‌​-2x_{i})$ for the reason I previously mentioned. However, I see absolutely no point in splitting it into a product of exponential functions - I cannot see how you would find a derivative of that, and for now I have no clue how you obtained your result. If could please include your intermediate steps, that would be great. – Johnny Westerling Oct 30 '12 at 15:26