Solution (source code)

= Solution

Here $X$ has the <binomial distribution> $\operatorname{Bin}(n,\theta)$, so, up to a factor independent of $\theta$, the <likelihood function> is
$$
L(\theta;X)=\theta^X(1-\theta)^{n-X}.
$$
For $0<X<n$, differentiating the <log-likelihood> gives
$$
\frac X\theta-\frac{n-X}{1-\theta}=0,
$$
and the boundary cases give the same formula. Thus the <binomial proportion maximum-likelihood estimator> is
$$
\boxed{\widehat\theta=\frac Xn}.
$$