# If $Z_n$ is distributed with binomial distribution with parameters $n$ and $p$, what is the MLE?

Suppose I have $Z_n \sim \text{Bin}(n,p)$.

When I set up the joint probability distribution to calculate the maximum likelihood estimator, I am confused how the product should look like since each random variable $Z$ is now a function of $n$, which coincides with the parameter $n$ in the binomial distribution.

I know the final answer should be $\hat{p}_n = Z_n / n$.

• Hi @user123276, let me know if i've accidentally changed your question. – BlackAdder Jan 24 '14 at 9:00
• Are you supposed to find the MLE of $p$ based on only one observation $Z_n$ with $n$ being fixed? – Stefan Hansen Jan 24 '14 at 10:31
• Usually in this sort of question, the parameter $n$ is known while the parameter $p$ is being estimated. – Henry Jan 24 '14 at 13:03

As Henry said, you will typically know $n$, you will also know the number of successes, $x$, hence your likelihood will look like this:${n\choose x} p^x(1-p)^{n-x}$. You want to optimize this wrt $p$ holding $x$ and $n$ constant. To simplify this problem, you can ignore the combinatorial factor at the front, as it is not affected by $p$. Taking the logarithm of the remaining factors will make our problem a little easier, giving us the loglikelihood:
$\mathcal{L}(p;x,n)=x\ln(p)+(n-x)\ln(1-p)$
Take the derivative of this wrt $p$ and set to 0:
$0= \frac{x}{p}-\frac{n-x}{1-p}\rightarrow \frac{x}{p}=\frac{n-x}{1-p}\rightarrow \frac{1-p}{p}=\frac{n-x}{x}\rightarrow \frac{1}{p}=\frac{n}{x}\rightarrow \hat p=\frac{x}{n}$
So, the value of $p$ that maximizes the likelihood of your data is the intuitive estimator: the number of successes divided by the total number of trials.