Stats - Likelihood function Let $X_1, X_2, \ldots , X_n$ be a random sample from a distribution with the following pdf
$$f(x|\theta) =  \begin{cases}
1/(\theta_2−\theta_1), &\quad\text {for}\quad \theta_1 \leq x\leq \theta_2\\
0 &\quad\text { otherwise}\quad
\end{cases}$$
Suppose that $\theta_1$ and $\theta_2$ are unknown.
How would I go about writing the likelihood function for this distribution on $\theta_1$ and $\theta_2$.
 A: 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)).
$$
A: $$
L(\theta_1,\theta_2) = \begin{cases} \frac{1}{(\theta_2-\theta_1)^n} & \text{for }\theta_2\ge\max\text{ and }\theta_1 \le\min \\[10pt]
0 & \text{for other values of }(\theta_1,\theta_2) \end{cases}
$$
where $\max=\max\{X_1,\ldots,X_n\}$ and $\min=\min\{X_1,\ldots,X_n\}$.
Draw the picture in the $(\theta_1,\theta_2)$ plane.
