# Maximum Likelihood estimator for n in binomial with known p

I have a question concerning the ML-estimation of the trials of a Binomial variable. The setting is the following:

I have a random variable $X\sim Bin(n,p)$ with $n\in\mathbb{N}$ unknown, $p\in (0,1)$ the known success probability and with density (w.r.t. to the counting measure) $p_n(x)=\binom{n}{x}p^x(1-p)^{n-x}=:L_x(n)$. The log-likehood function is therefore given by $$l_x(n)=\log L_x(N)=\log(n!)-\log(x!)-\log((n-x)!)+x\log(p)+(n-x)\log(1-p) .$$ Maximizing $l_x(n)$ w.r.t. to $n$ is equivalent to maximizing $\log(n!)-\log((n-x)!)+n\log(1-p)$ or $\frac{n!}{(n-x)!}(1-p)^n$.

My problem is that I don't know how to proceed from here. A person in this thread Maximum likelihood estimate of $N$ (trials) in Binomial suggested that a solution is given by $\hat{n}=X/p$. However, $X/p\notin \mathbb{N}$ for most $p$, so I suspect that this can't be the answer.

• This might help. Jan 30, 2018 at 16:47
• Thx, but this is deriving the MLE for p not n Jan 30, 2018 at 16:50
• Can you follow the procedure and adapt it so it fits your variable? Jan 30, 2018 at 16:56
• I don't see how the "standard MLE procedure" applies here. Taking the derivative of the log likelihood functino wrt to $n$ ends up with messy terms involving the derivative of $n!$ Jan 30, 2018 at 17:14
• I think the result might turn messy, but do you know about the gamma function? Jan 30, 2018 at 17:19

Consider $\dfrac{{n+1 \choose x}p^x(1-p)^{n+1-x}}{{n \choose x}p^x(1-p)^{n-x}} = \dfrac{(n+1)}{(n+1-x)}(1-p)$ which is less than $1$ when $n > \dfrac{x}{p}-1$, and so choosing $n+1$ in such a case would not give you a maximum likelihood estimate
Thus, given $x$ and $p$, your maximum likelihood estimate of $n$ is $\bigg\lfloor\dfrac{x}{p}\bigg\rfloor$ (rounding down)
unless $\dfrac{x}{p}$ is an integer in which case there are two with equal likelihood: $\dfrac{x}{p}-1$ and $\dfrac{x}{p}$
• @DavidRefaeli One way of finding whether one likelihood is greater than another is to divide one by the other and compare the result with $1$. The actual division shows that any choice over $\frac x p$ does not give a maximum and also that any choice below $\frac x p -1$ also fails to give a maximum. That is why you round down Feb 10, 2020 at 17:37
• @DavidRefaeli In the original question there was a single sample. There is an implicit indicator function in that that for the likelihood to be non-zero you need $n \ge x$ but that is not a problem as $\lfloor\frac{x}{p}\rfloor \ge x$. In your example with three samples, the maximum likelihood estimator would be different both because you start with $\prod\limits_i \frac{{n+1 \choose x_i}p^{x_i}(1-p)^{n+1-x_i}}{{n \choose x_i}p^{x_i}(1-p)^{n-x_i}}=\frac{(n+1)^3}{\prod(n+1-x_i)}(1-p)^3$ and because the estimator should explicitly be at least $\max(x_i)$ Feb 10, 2020 at 21:08