# How to take derivative of this likelihood function?

I am working with the probability likelihood function $$\log \prod\limits_{i=1}^{n} x_i^{y_i} + \log \prod\limits_{i=1}^{n}\left(1-{{x}_{i}}\right)^{n_i-y_i}.$$
I want to take the derivative with respect to $x_i$.

How should I do it? Thanks in advance.

-
You'll need the chain rule and a memory of logarithm identities, e.g. $\log(a^b c^d)=b\log\,a+d\log\,c$... –  Ｊ. Ｍ. May 2 '12 at 17:57
how do I take derivative of a product? –  edwin May 2 '12 at 18:05
What you actually have is the logarithm of a product, so you can use that identity I mentioned earlier before differentiating... –  Ｊ. Ｍ. May 2 '12 at 18:06
are you saying: $\log \prod\limits_{i=n}^{n}{{{y}_{i}}}\prod\limits_{i=n}^{n}{{{x}_{i}}}+\log \prod\limits_{i=1}^{n}{({{n}_{i}}-{{y}_{i}})}\prod\limits_{i=1}^{n}{(1-{{x}_{i}}‌​)}$ –  edwin May 2 '12 at 18:09
$=\log \prod\limits_{i=n}^{n}{{{y}_{i}}}+\prod\limits_{i=n}^{n}{{{x}_{i}}}+\log \prod\limits_{i=1}^{n}{({{n}_{i}}-{{y}_{i}})}+\prod\limits_{i}^{n}{(1-{{x}_{i}})‌​}$ @J.M. –  edwin May 2 '12 at 18:14

$$\log \prod\limits_{i=1}^{n} x_i^{y_i} + \log \prod\limits_{i=1}^{n}\left(1-{{x}_{i}}\right)^{n_i-y_i} =\sum_{i=1}^{n} {y_i}\log x_i + \sum\limits_{i=1}^{n} ({n_i-y_i})\log \left(1-{{x}_{i}}\right)$$

so the derivative you are looking for is $\dfrac{y_i}{x_i} - \dfrac{n_i-y_i}{1-x_i}$. This will be zero when $x_i=\frac{y_i}{n_i}$ which probably has an intuitive interpretation.

-
There seems to be a stray product on the right-hand side... –  Ｊ. Ｍ. May 2 '12 at 19:04
@J.M.:indeed - thank you –  Henry May 2 '12 at 20:15

Does this look right?
\log \prod\limits_{i=1}^{m}{\left( \begin{align} & {{n}_{i}} \\ & {{y}_{i}} \\ \end{align} \right)\theta _{i}^{{{y}_{i}}}{{(1-{{\theta }_{i}})}^{{{n}_{i}}-{{y}_{i}}}}}
$=\log \prod\limits_{i=n}^{n}{{{\theta }_{i}}^{{{y}_{i}}}}+\log \prod\limits_{i}^{n}{{{(1-{{\theta }_{i}})}^{{{n}_{i}}-{{y}_{i}}}}}$ \text{Note: I ignored the therm } \left( \begin{align} & {{n}_{i}} \\ & {{y}_{i}} \\ \end{align} \right) $=\sum\limits_{i=1}^{m}{{{y}_{i}}\log {{\theta }_{i}}}+\sum\limits_{i=1}^{m}{({{n}_{i}}-{{y}_{i}})\log (1-{{\theta }_{i}})}$

Calculating first derivative:
$$\frac{\partial }{\partial \theta }=\frac{\sum{{{y}_{i}}}}{{{\theta }_{i}}}-\frac{\sum{({{n}_{i}}-{{y}_{i}})}}{1-{{\theta }_{i}}}=0$$ $$\frac{\sum{{{y}_{i}}}}{{{\theta }_{i}}}=\frac{\sum{({{n}_{i}}-{{y}_{i}})}}{1-{{\theta }_{i}}}$$ $$\sum{{{y}_{i}}-{{\theta }_{i}}\sum{{{y}_{i}}={{\theta }_{i}}\sum{({{n}_{i}}-{{y}_{i}})}}}$$ $$\sum{{{y}_{i}}={{\theta }_{i}}\left( \sum{({{n}_{i}}-{{y}_{i}})+\sum{{{y}_{i}}}} \right)}$$ $$\sum{{{y}_{i}}={{\theta }_{i}}(\sum{{{n}_{i}}})}$$ $${{\hat{\theta }}_{i}}=\frac{\sum{{{y}_{i}}}}{\sum{{{n}_{i}}}}$$

-
this is wrong! We are taking derivative w.r.t. each ${\theta}_{i}$ –  user1061210 May 2 '12 at 19:47