# Maximum likelihood estimator for non-standard distribution

This is a question from an old exam-paper:
"Suppose that we have data $$y = (y_1, . . . , y_n)$$. Each data-point $$y_i$$ is assumed to be generated by a distribution with the following probability density function: $$p(y_i|\theta)=\frac{\theta^2}{y_i^3}e^{-\frac{\theta}{y_i}},y_i\ge0$$ The unknown parameter is $$\theta$$, with $$\theta>0$$. Write down the likelihood for $$\theta|y$$. Find an expression for the maximum likelihood estimate $$\hat{\theta}$$."

My approach is as follows:
$$L(\theta;y) = \prod_{i=1}^n \frac{\theta^2}{y_i^3}e^{-\frac{\theta}{y_i}},y_i\ge0$$
Now, $$\prod_{i=1}^n \theta^2=\theta^{2n}$$ $$\prod_{i=1}^n \frac{1}{y_i^3}=\frac{1}{(\prod y_i)^3}$$ and $$\prod_{i=1}^n e^{-\frac{\theta}{y_i}}=e^{-\theta \sum\frac{1}{y_i}}$$

So overall, $$L(\theta;y)=\theta^{2n} \frac{1}{(\prod y_i)^3} e^{-\theta \sum\frac{1}{y_i}}$$

The log-likelihood is $$\ell(\theta;y)=2n\ln(\theta) + \ln\left(\frac{1}{(\prod y_i)^3}\right) -\theta \sum\frac{1}{y_i}$$ Where all the products and sums happen over $$i=1,2,3,\dots,n$$.

Differentiating with respect to $$\theta$$:$$\frac{d\ell}{d\theta}=\frac{2n}{\theta}-\sum\frac{1}{y_i}=0$$
This implies that $$\hat{\theta}=\frac{2n}{\sum\frac{1}{y_i}}$$

Is the likelihood and the MLE correct?

Yes, this all looks right to me. Note that this is

$$\hat\theta=\frac2{\left\langle\frac1y\right\rangle}$$

with

$$\left\langle\frac1y\right\rangle=\frac1n\sum_i\frac1{y_i}\;,$$

the sample mean of $$\frac1y$$. Note also that you could transform to $$Z=\frac1Y$$ with density

$$\frac{\theta^2}{y^3}\mathrm e^{-\frac\theta y}\left|\frac{\mathrm d y}{\mathrm d z}\right|=\theta^2z\mathrm e^{-\theta z}$$

and obtain the same result

$$\hat\theta=\frac2{\langle z\rangle}\;.$$