3
$\begingroup$

I am having quite some troubles with the following homework:

In a city it's measured for the whole year whether it rained or not. A distribution $\textrm{Bernoulli}(r_t|\rho)$ characterizes the observations $\{r_t\}_{t=1}^{365}$ where $r_t = 1$ if it rained that day and $r_t = 0$ if it did not rain.

My goal is finding the value of $\rho$ as a maximum likelihood.

One first step is to find the likelihood of the entire set of observations, which I believe is:

$p(r_1,r_2,\ldots,r_t|\rho) = \prod_{t=1}^{365}\rho^{r_t}(1 - \rho)^{1-r_t}$

Considering $n_1$ as the number of rainy days, and $n_0$ the number of not raining days the likelihood is simplified:

$p(r_1,r_2,\ldots,r_t|\rho) =\rho^{n_1}(1 - \rho)^{n_0}$

Hence, the log-likelihood calculated as follows:

$\mathrm{log}p(r_1,r_2,\ldots,r_t|\rho) = n_1\mathrm{log}(\rho) + n_0\mathrm{log}(1-\rho)$

Its derivative seems to be:

$\frac{\mathrm{d}}{\mathrm{d}\rho}\mathrm{log}p(r_1,r_2,\ldots,r_t|\rho) = \frac{n_1}{\rho} + \frac{n_0}{1- \rho}$

Setting the derivative to 0:

$\rho = \frac{n_1}{n_1 - n_0}$

Plugging in the yearly measurements $n_1 = 217$, $n_0 = 148$:

$\rho = \frac{217}{217-148} = 3.145$

Unfortunately this value is not allowed for $\rho$, which should be in the interval $[0,1]$.

What's wrong? I did the calculations several times with the same result.

$\endgroup$

1 Answer 1

6
$\begingroup$

$$\frac{d \log(p)}{d \rho} = \frac{n_1}{\rho} - \frac{n_0}{1-\rho} \Rightarrow \rho = \frac{n_1}{n_0+n_1}$$

$\endgroup$
3
  • $\begingroup$ hmm, why do you have a minus between $n_1/\rho$ and $n_0/(1-\rho)$ ? $\endgroup$
    – fstab
    Sep 17, 2014 at 11:30
  • 2
    $\begingroup$ I don't know why someone downvoted this answer since it correctly points out that the OP mistakenly wrote the derivative of $\log(1-\rho)$ as $\frac{1}{1-\rho}$ instead of as $-\frac{1}{1-\rho}$ as told to us by the chain rule of differentiation. $\endgroup$ Sep 17, 2014 at 14:05
  • 3
    $\begingroup$ francesco the minus is there because $\frac{d}{d\rho} \log(1-\rho)=\frac{1}{1-\rho}\cdot -1$ by the chain rule of differentiation. $\endgroup$
    – Glen_b
    Sep 17, 2014 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.