For geometric distribution, the pmf is given by$$f (x, p) = p(1 − p)^{x−1} , 0 ≤ p ≤ 1, x = 1, 2, 3, \cdots $$Hence, the likelihood function is$$\mathcal{L}(p)=\prod_{i=1}^nf(x_i,p)=p^n(1-p)^{-n+\sum_{i=1}^nx_i}$$Taking the natural logarithm of $\mathcal{L}(p)$,$$\ln \mathcal{L}=n\ln p+\left(-n+\sum_{i=1}^nx_i\right)\ln(1-p).$$Taking the derivative with respect to $p$, we have$$\frac{d\ln \mathcal{L}}{dp}=\frac{n}{p}-\frac{\left(-n+\displaystyle\sum_{i=1}^nx_i\right)}{1-p}$$Equating this to zero, we have$$\frac{n}{p}-\frac{\left(-n+\displaystyle\sum_{i=1}^nx_i\right)}{1-p}=0$$Solving for $p$,$$p=\frac{n}{\sum_{i=1}^nx_i}=\frac{1}{\bar{x}}$$Thus, we obtain a maximum likelihood estimator of $p$ as$$\widehat{p}=\frac{n}{\displaystyle\sum_{i=1}^nX_i}=\frac{1}{\bar{X}}$$
wxMaxima Programming: Geometric Distribution Maximum Likelihood Estimation