# Calculating the Maximum Likelihood Estimate

I'm trying to understand MLE, but struggling with a question/example, so was hoping for an explanation if someone can help.

There's a ring toss game which is repeated until it's succeeds for the first time. Each time the game is played, it succeeds with the probability p; and each attempt is independent.

I have the following probability function of X. $$\ f(x)=p(1−p)^{x-1}$$

I'm trying to work out the MLE of p (given a single observation x of X). Would someone know how to go about this? What I'm struggling with here is that the number of attempts, as it isn't fixed and instead is just 'n'.

Your likelihood function is $$L(p \mid x) = p \left(1 - p\right)^{x - 1}.$$ Differentiating with respect to $$p$$, \begin{aligned} \frac{d L}{d p}(p \mid x) &= \left(1 - p\right)^{x - 1} - p (x - 1) \left(1 - p\right)^{x - 2} \\ &= (1 - p)\left(1 - p\right)^{x-2} - (p x - p) \left(1 - p\right)^{x - 2} \\ &= (1 - p - p x + p) \left(1 - p\right)^{x - 2} \\ &= (1 - p x) \left(1 - p\right)^{x - 2}. \end{aligned} Setting this equal to zero (since the derivative of $$L(p \mid x)$$ at $$p$$ is zero if $$L(p \mid x)$$ is at a maximum), we get $$(1 - p x) \left(1 - p\right)^{x - 2} = 0.$$ Assuming $$p < 1$$, it follows that $$\left(1 - p\right)^{x - 2} \neq 0$$, so $$1 - p x = 0$$, and hence $$p = 1 / x$$. Thus, the maximum likelihood estimate of $$p$$ is $$\hat{p} = \frac{1}{x}.$$

• You should avoid giving out questions to homework questions. Instead, consider giving hints. – StatsStudent Feb 7 '19 at 1:30
• @Ben sure, but this case is so easy there's no need to take logs in my opinion – Artem Mavrin Feb 7 '19 at 1:34
• Agree - either method is fine in this case. – Ben - Reinstate Monica Feb 7 '19 at 1:35
• Just to improve this answer, may I recommend that you use $\hat{p}$ to denote the estimator, rather than $p$. Also, it would be worth flagging what happens to the MLE when $x=0$, since in that case, your expression for the estimator is undefined. – Ben - Reinstate Monica Feb 7 '19 at 1:36
• @StatsStudent I think sometimes it’s useful to see an entire answer worked out so that you can learn how to approach similar problems – Artem Mavrin Feb 7 '19 at 1:38

Since you have a single observation, you have $$n=1$$. So the likelihood function for the observed data is:

$$L_x(p) = p(1-p)^{x-1} \quad \quad \quad \text{for all } 0 \leqslant p \leqslant 1.$$

As the name suggests, the maximum-likelihood estimator is the value that maximises the likelihood function:

$$\hat{p}(x) = \underset{0 \leqslant p \leqslant 1}{\text{arg max }} L_x(p)$$

In this particular case, this is just a basic calculus problem, where you are trying to maximise the likelihood function with respect to a continuous argument variable. Since the likelihood function is a product of non-negative parts that depend on $$p$$, it is usual to find the maximising value by maximising the log-likelihood function (i.e., the logarithm of the likelihood function). If you apply standard calculus methods to maximise this function, you will be able to derive the maximum-likelihood estimator $$\hat{p}$$.