# What is the maximum likelihood of a binomial distribution?

i've looked everywhere I could for an answer to this question but no luck ! If I have $$X_1 .... X_n$$ random variables that are independent and identically distributed such as ∀ $$1 <$$ $$i$$ $$, $$X_i$$ ~ B(n,$$\theta$$) (binomial distribution)

I know that the likelihood is :

$$P_n$$($$\theta$$,x)=$$\prod\limits_{i}$$ $$\binom{n}{x_i}p^{x_i}(1-p)^{n-x_i}$$

but then it seems kind of hard to calculate as product, I tried to calculate log($$p_n$$) but then the $$x_i$$! causes me problems

Can you enlighten me ? what is the max-likelihood of a binomial distribution ?

Take the log-likelihood function, i.e. $$L(p) = \log \prod_i \binom{n}{x_i} p^{x_i}(1-p)^{n-x_i}$$ which becomes $$L(p) = \sum_i \log\binom{n}{x_i} p^{x_i}(1-p)^{n-x_i}$$ even more $$L(p) = \sum_i \log\binom{n}{x_i} + \sum_i x_i\log p + \sum_i(n-x_i)\log(1-p)$$ Since you're interested in the ML estimate of $$p$$. let's derive with respect to $$p$$ and set it to zero. $$\frac{d}{dp}L(p) = \frac{1}{p}\sum_i x_i - \frac{1}{1-p}\sum_i(n-x_i) = 0$$ which gives you $$\frac{1}{1-p}\sum_i(n-x_i) = \frac{1}{p}\sum_i x_i$$ or $$\frac{\sum_i(n-x_i)}{\sum_i x_i} = \frac{1-p}{p} = \frac{1}{p} - 1$$ Now find $$p$$. $$\frac{1}{p} = \frac{\sum_i(n-x_i) + \sum_i x_i}{\sum_i x_i} = \frac{\sum_i n}{\sum_i x_i}$$