[Math] Maximum likelihood for an erlang distribution

machine learningmaximum likelihoodpattern recognitionstatistics

I have a hard time approaching this problem. I understand how to find the MLE for common distributions, such as binomial. From the given problem below, I can see that $u(x)$ can take two values, but can't figure what values does $x$ take.

Assume that $n$ random non-negative real valued samples of $x_1, x_2, \cdots, x_n$ have been drawn independently from Erlang Distribution with the following probability density function which has only one parameter of $\theta$ (theta). Here $\theta$ (theta) is a non- negative scalar value, and $u(x)$ is the unit step function defined as follows:

$$
p(x|\theta) = \theta^2x e^{-\theta x}u(x)~~~\mbox{where}~~~u(x)~~~\mbox{is}~~~ u(x) = \begin{cases}1 & \mbox{if}~ x>0\\0 & \mbox{if}~ x<0 \end{cases}
$$

Find the maximum likelihood estimate for the parameter $\theta$ (theta) based on the values of these $n$ samples.

Best Answer

Calculate

$$ \mathcal{L} = \prod_{i=1}^np(x_i|\theta) = \theta^{2n}e^{-\theta\sum_{i=1}^nx_i}\prod_{i=1}^n x_i \underbrace{u(x_i)}_{\color{blue}{1,}~~{\rm c.f.}~ x_i>0} $$

So that

$$ \ln\mathcal{L} = 2n\ln\theta -\theta \sum_{i=1}^nx_i + \sum_{i=1}^nx_i =2n\ln\theta -n \theta \bar{x} + n\bar{x} $$

where $\bar{x} = n^{-1}\sum_{i=1}^nx_i$. Taking the derivative of this last expression you get

$$ \frac{{\rm d}\mathcal{L}}{{\rm d}\theta} = -n\bar{x} + \frac{n}{\theta} $$

So that the ML estimate of theta is

$$ \hat{\theta} = \frac{1}{\bar{x}} $$