MLE of uniform distribution on the interval $[\theta − \frac{1}{2}, \theta + \frac{1}{2}]$

$X_1, X_2, . . . , X_n$ are i.i.d. observations from a uniform distribution on the interval $[\theta − \frac{1}{2}, \theta + \frac{1}{2}]$.

Show that any $\theta$ between $X_{max} − \frac{1}{2}$ and $X_{min} + \frac{1}{2}$ maximizes the likelihood, and therefore, can be taken as the MLE.

I am confused...because $f(x|\theta) = \frac{1}{(\theta+\frac{1}{2}) -(\theta -\frac{1}{2})} = 1$ for $\theta-\frac{1}{2} \le x \le\theta+\frac{1}{2}$ and 0 otherwise... Isn't the likelihood function $L(x|\theta) = 1$?

The how can it be maximized between $X_{max} − \frac{1}{2}$ and $X_{min} + \frac{1}{2}$ ?


Solution 1:

The likelihood function is not $L(x|\theta)$. It is $L(X_1,\ldots,X_n|\theta)$ and is considered as a function of the variable $\theta$.

Firstly rewrite pdf and express $\theta$ from the inequality $\theta-\frac{1}{2} \le x \le\theta+\frac{1}{2}$ with respect to $x$: $$ f(x|\theta) = \begin{cases}1, & \theta-\frac{1}{2} \le x \le\theta+\frac{1}{2}\\ 0 & \text{ else}\end{cases} = \begin{cases}1, & x-\frac{1}{2} \le \theta \le x+\frac{1}{2}\\ 0 & \text{ else}\end{cases} $$ Next find the likelihood function: $$ L(X_1,\ldots,X_n|\theta)=f(X_1|\theta)\cdot\ldots\cdot f(X_n|\theta).$$ This product equals to $1$ iff $$X_i-\frac{1}{2} \le \theta \le X_i+\frac{1}{2}\quad \text{ for all } i=1,2,\ldots,n$$ or, equivalently, if $$X_{max}-\frac{1}{2} \le \theta \le X_{min}+\frac{1}{2}$$ Then $$ L(X_1,\ldots,X_n|\theta)=\begin{cases}1, & X_{max}-\frac{1}{2} \le \theta \le X_{min}+\frac{1}{2}\\ 0 & \text{ else}\end{cases} $$