$95$% confidence interval for $\theta_2-\theta_1$ from $\text{uniform}\left(\theta_1,\theta_2\right)$ I want to find a $95$% confidence interval for $\theta_2-\theta_1$ where $X_1,...,X_n$ are the random sample from $U(\theta_1,\theta_2)$, the uniform distribution with two parameters  $\theta_1, \theta_2$.
I have the maximum likelihood estimators $\hat\theta_1=X_{(1)}$, the minimum order statistic, and $\hat\theta_2=X_{(n)}$, the maximum order statistic. But I don't know how to compute the confidence interval of $\theta_2-\theta_1$.
Is there anyone can help me?
Thanks for your help
 A: Let $\delta := \theta_2 - \theta_1$ and $Z_i := \theta_1 + X_i$. We have $Z_i \sim \text{Unif}(0,\delta)$, and $X_{(1)} = \theta_1 + Z_{(1)}$ and $X_{(n)} = \theta_1 + Z_{(n)}$. Then, $$R := X_{(n)} - X_{(1)}  = Z_{(n)} - Z_{(1)}$$ is a good estimate of $\delta$. 
We note that $[Z_{(n)} - Z_{(1)}]/\delta$ is a pivot, i.e. its distribution does not depend on $\delta$ and it is easy to find out. This can be used to construct the CI.
Hint: Note that $U_i := Z_i/\delta$ is uniform $(0,1)$. You are basically computing the distribution of $U_{(n)} - U_{(1)}$.  You can either use the known joint distribution of $(U_{(1)},U_{(n)})$ or do it directly yourself:
\begin{align}
\mathbb P(U_{(n)} - U_{(1)} \le t) &= \mathbb P(U_{(n)} \le t +  U_{(1)}) \\
&=\mathbb \int_0^1 \mathbb P[U_{(n)} \le t +  u, \; U_{(1)} \in (u,u+du)]
\end{align}
The integrand is the probability that the minimum is about $u$ and the rest of them are $\in(u, t+u)$. There are $n$ possible choices for which one of the variables is the minimum, and all these events have the same probability $  du (\min\{t+u,1\}-u)^{n-1}$.
Hence,
$$
p(t) := \mathbb P(U_{(n)} - U_{(1)} \le t) = n\int_0^1 (\min\{t+u,1\}-u)^{n-1} du.
$$
which can be simplified and explictly computed $=n(1-t)t^{n-1} + t^n$ for $t \in [0,1]$.
Choose $t_1$ and $t_2$ such that $p(t_2)-p(t_1) = 0.95$. Then $[R/t_2,R/t_1]$ is a 95% CI for $\delta$. You can try to minimize the length, by minimizing $|1/t_2 - 1/t_1|$ subject to the given constraint.
Some more details: Let $A := \{U_{(n)} \le t +  u, \; U_{(1)} \in (u,u+du)\}$. We can write (assume $t > du$ for this to formally be true)
\begin{align*}
A &= \bigcup_{i=1}^n \{U_{(n)} \le t +  u, \; U_{(1)} \in (u,u+du), U_{(1)} = i\} \\
&= \bigcup_{i=1}^n \{ U_j \le t +  u,\, \forall j\neq i, \;\; U_{i} \in (u,u+du), \;\;U_{(1)} = i\} \\
&=\bigcup_{i=1}^n \{ U_i < U_j \le t +  u,\, \forall j\neq i, \;\; U_{i} \in (u,u+du)\} \\
&\approx \bigcup_{i=1}^n \underbrace{\{ u+ du < U_j \le t +  u,\, \forall j\neq i, \;\; U_{i} \in (u,u+du)\}}_{A_i}
\end{align*}
The last one is really $\supset$ in place of $\approx$, but one somehow argues that as $du \to 0$, it approaches the desired set. The sets $A_i$ are disjoint (for example on $A_1$, $U_1$ is in $(u,u+du)$ while it is in $(u+du,t+u)$ in all other $A_j, j\neq 1$), hence $\mathbb P(A) = \sum_{i=1}^n \mathbb P(A_i)$. By symmetry $P(A_i)$ are the same for all $i$, hence $ \mathbb P(A) = n \mathbb P(A_1)$, and
$$
\mathbb P(A_1) = \Big[\prod_{j=2}^n \mathbb P( u + du < U_j \le t+u) \Big]\mathbb P( U_1 \in (u,u+du))
$$
by indepedence.
