Finding MLE of $f(x;\theta) =1$ if $\theta-1/2Let $X_1,...,X_n$ have density:
$$f(x;\theta) = \begin{cases} 1 & \text{if } \theta-1/2<x< \theta+1/2 \\ 
0 & \text{otherwise} \end{cases}$$
Let $Y_1=\min \lbrace X_1,\ldots,X_n \rbrace$ and $Y_n=\max \lbrace X_1,\ldots,X_n\rbrace$
Show that any statistic $u(X_1,\ldots,X_n)$ that satisfies $Y_n-1/2<u<Y_1+1/2$ is a maximum likelihood estimate of $\theta$.
My attempt:
First rewrite the density:
$$f(x;\theta) = \begin{cases} 1 &\text{if } -1/2<x- \theta<1/2 \\ 
0 & \text{otherwise} \end{cases}$$
Okay, so we obviously need to use the fact that $Y_n-1/2<u<Y_1+1/2$, I started by using the regular MLE finding method:
$$L(\theta)=\prod_i(x-\theta)$$
$$\log L(\theta)=\log\prod_i(x_i-\theta)=\sum_i \log(x_i- \theta)$$
$$(\log L(\theta))'=\sum_i \frac 1 {x_i- \theta} =0$$
And I'm stuck here..I think that I need to use the given here but I'm not sure how to proceed.
Any help would really be appreciated:) Thanks!
 A: Here, the density is $f_\theta(x) = 1_{|x-\theta|\le \frac 12}$.
The likelihood is a product of such this function evaluated on realizations,so it is 0 or 1.
So now the set of MLEs is the set $$\{\theta \mid \forall i\, f_\theta(X_i)=1\}
=\{\theta\mid \forall i\, X_i - \frac 12 \le \theta \le X_i + \frac 12 \}
=[\max X_i- \frac 12 , \min X_i + \frac 12]
$$
as wanted.
A: The piecewise nature of the density, and hence of the likelihood, is the essence.
$$
f_{X_1}(x\mid \theta) = 1\text{ if } \theta-\frac12 < x < \theta+\frac 12.
$$
$$
f_{(X_1,\ldots,X_n)}(x_1,\ldots,x_n) = 1\text{ if for all }i\in\{1,\ldots,n\}\text{ we have }\theta-\frac12<x_i<\theta+\frac 12.
$$
The words after "if" are equivalent to
$$
\theta - \frac 1 2 < \min\{X_1,\ldots,X_n\} \text{ and } \max\{X_1,\ldots,X_n\} < \theta+\frac 1 2,
$$
and hence to
$$
\max-\frac12 < \theta < \min+\frac12.
$$
So
$$
L(\theta) = \begin{cases} 1 & \text{if }\max-\frac 12<\theta <\min+\frac 1 2, \\ 0 & \text{otherwise}. \end{cases}
$$
This is always either $0$ or $1$.  It achieves its maximum at those points where it is equal to $1$.
The $\text{“}(x_i-\theta)\text{''}$ is wildly out of place: neither the density nor the likelihood is equal to $x_i-\theta$ or to a product of those.
