# How to find the MLE for discrete parameters?

Let $$\mathrm{X}_{1}, \mathrm{X}_{2}, \ldots, \mathrm{X}_{n}$$ be a random sample from a distribution with one of two possible pdfs: $$f(x ; \theta)=\left\{\begin{array}{ll}{\frac{1}{\sqrt{2 \pi}} e^{-x^{2} / 2},} & {-\infty Find the MLE $$\hat{\theta}$$ for $$\theta \in\{1,2\}$$.

if I understand correctly what the MLE is, it's the value of $$\theta$$ (could depend on the $$X_i$$'s) that maximizes the likelihood function.

by the positivity of things, it should be just a matter of comparing the two possible pdfs, however none of them is all the time bigger than the other, so what do we do here ? does the MLE just doesn't exist ?

• See similar question: math.stackexchange.com/questions/3256569/…. Oct 26, 2019 at 19:48
• @StubbornAtom it was some time ago but I did know how to solve it thanks to your answer on the other similar thread, will post an answer soon. Feb 17, 2020 at 15:01

suppose we define a function $$I(\theta)=\begin{cases}1&,\text{ if }\theta=1 \\ 0&,\text{ if }\theta=2\end{cases}$$
Then the likelihood function given the data $$x_1,\ldots,x_n\in(-\infty,\infty)$$ can be expressed as
$$L(\theta)=\left( \frac{e^{-\frac12 \sum_{i =1}^{n} x_i^2}}{(2\pi)^{\frac{n}{2}}} \right)^{I(\theta)}\left(\frac{1}{\pi^n \prod_{i=1}^n(1+x_i^2)}\right)^{1-I(\theta)}\quad,\theta\in\{1,2\}$$
Clearly, $$L(1)=\frac{e^{-\frac12 \sum_{i =1}^{n} x_i^2}}{(2\pi)^{\frac{n}{2}}}$$ and $$L(2)=\left(\pi^n \prod_{i=1}^n(1+x_i^2)\right)^{-1}$$ for all $$x_i\in(-\infty,\infty)$$.
So the MLE of $$\theta$$ must be $$\hat\theta=\begin{cases}1&,\text{ if } (\frac{\pi}{2})^{\frac n2} e^{-\frac12 \sum_{i =1}^{n} x_i^2}\prod_{i=1}^n(1+x_i^2)>1 \\ 2&,\text{ if }(\frac{\pi}{2})^{\frac n2} e^{-\frac12 \sum_{i =1}^{n} x_i^2}\prod_{i=1}^n(1+x_i^2)\le1\end{cases}$$