# 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. – TheSimpliFire Jan 30 '18 at 16:47
• Thx, but this is deriving the MLE for p not n – J.Kar Jan 30 '18 at 16:50
• Can you follow the procedure and adapt it so it fits your variable? – TheSimpliFire Jan 30 '18 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!$ – J.Kar Jan 30 '18 at 17:14
• I think the result might turn messy, but do you know about the gamma function? – TheSimpliFire Jan 30 '18 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}$