Maximum Likelihood Estimation Question 
Consider the probability density function
  $$f(x)=\frac{1}{\theta^2}xe^{-x/\theta},\;\;\;\;\; 0\le w\lt\infty,\;\;0\lt\theta\lt\infty$$
  Find the maximum likelihood estimator for $\theta$.

I'm really struggling with this question. From my understanding in order to find the maximum likelihood estimator for $\theta$, the function needs to be partially differentiated with respect to $\theta$, equated to zero, and solved for $\theta$; however for this question the differentiation is very messy and even more difficult, is solving the derivative for $\theta$.
 A: The likelihood function is given by:
$$
L(\theta)=\prod_{i=1}^nf(\theta|x_i)=\prod_{i=1}^n\theta^{-2}x_ie^{\frac{-x_i}{\theta}}=\theta^{-2n}\left(\prod_{i=1}^nx_i\right) exp\left(\frac{-1}{\theta}\sum_{i=1}^nx_i\right)
$$
Taking the log, to find the log-likelihood:
$$
l(\theta)=log(L(\theta))=-2nlog(\theta)+\sum_{i=1}^nlog(x_i)-\frac{1}{\theta}\sum_{i=1}^nx_i
$$
Maximizing this is much simpler, find the derivative with respect to $\theta$ and setting equal to zero:
$$
l'(\theta)=-\frac{2n}{\theta}+\frac{1}{\theta ^2}\sum_{i=1}^n
x_i=0$$
I'll leave solving for theta to you
A: If we have $ n $ sample size, then likelihood is $ L(x,\theta)= \prod f(x_i) $
So $ L(x,\theta)= (1/\theta^{2n})\prod x_i e^{-\sum x_i/\theta} $
Since $ 0<\theta <\infty $. We can use likelood as $ log L $.
So $ log L = -2nlog\theta + \sum logx_i -\sum x_i /\theta $
differentiate with respect to $\theta$ and equate with $ 0$ we get $\theta_0 = \sum x_i/2n $. $ \frac {\partial log L}{\partial \theta}= -2n/\theta + \sum x_i /\theta^2 = 0 $ . So estimate $\theta_0 = \sum x_i/2n $. Now we check it maximises our likelihood. $ \frac {\partial^2 logL}{\partial \theta^2} = +2n/\theta^2 - 2\sum x_i/\theta^3 $.
Put $ \theta = \sum x_i/2n $ we have $ \frac {\partial^2 logL}{\partial \theta^2} = 8 n^3/ (\sum x_i)^2 -16 n^3/ (\sum x_i)^2 $ which is negative. So $ \theta = \sum x_i/2n $ is maximum likelihood estimates.
