# 95% confidence interval for $\theta_2-\theta_1$ from $uniform(\theta_1,\theta_2)$

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?

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.

• This is excellent. Saw this problem and was trying to compute the distribution of the difference of order statistics directly from joint pdf. It was a pain. I have never seen your method of computing the distribution of difference of r.v. before. Does this always work / do you usually do this? And I want to make sure I'm thinking of it right... Want smallest r.v. in $(u,u+du)$, and the rest to be between $u$ ( why not $u + du$?) and $t+u$. There are $n$ possibilities for smallest, so $n \; du$, and multiply this by $(P[u \le U_i \le t+u])^{n-1}$ since order doesn't matter here. – user288742 Dec 3 '16 at 1:25
• @user288742, all those joint PDFs can be obtained by similar techniques. You can argue directly about the PDFs this way too. It generally works well for order statistics (esp. the two extremes). Re your first question, yes, you can say that the rest are in $(u+du, t+u)$, but in the limit that is the same as $(u,t+u)$ in the first order. In other words, that addition will add terms of order $(du)^i$ for $i=2,3,\dots$ which are negligible in this case relative to the first order term. Consider expanding $(\max\{t+u,1\} -u - du)^{n-1} du$ and see what terms you get. – passerby51 Dec 3 '16 at 5:37
• @user288742, Re your second comment, yes, more or less. I will add some more details. – passerby51 Dec 3 '16 at 5:38
• Thanks for all the help - i have to wait to give you the bounty points. I will take a closer look in the morning and perhaps ask you more questions too. And for finding the "optimal" confidence interval, could that be done with Lagrange multipliers? I tried it quickly but got nothing worthwhile. – user288742 Dec 3 '16 at 6:53