Stats - Likelihood function
Solution 1:
The easiest way might be to begin by writing the density as it should be written, that is, as $$ f(x\mid\theta)=\frac{\mathbf 1_{\theta_1\leqslant x\leqslant\theta_2}}{\theta_2-\theta_1}, $$ where $\theta=(\theta_1,\theta_2)$ with $\theta_1\lt\theta_2$. Then the likelihood of an i.i.d. sample $\mathbf x=(x_1,\ldots,x_n)$ is $$ f(\mathbf x\mid\theta)=\prod_{k=1}^nf(x_k\mid\theta)=\frac{\mathbf 1_{\theta_1\leqslant m_n(\mathbf x),s_n(\mathbf x)\leqslant\theta_2}}{(\theta_2-\theta_1)^n}, $$ where $$ m_n(\mathbf x)=\min\{x_k\mid 1\leqslant k\leqslant n\}, \qquad s_n(\mathbf x)=\max\{x_k\mid 1\leqslant k\leqslant n\}. $$ For every fixed $\mathbf x$, $f(\mathbf x\mid\theta)$ is maximal when $\theta_2-\theta_1$ is as small as possible hence the MLE for $\theta=(\theta_1,\theta_2)$ based on $\mathbf x$ is $$ \widehat\theta(\mathbf x)=(m_n(\mathbf x),s_n(\mathbf x)). $$