The maximum and minimum of five independent uniform random variables Let $U_1,\dots,U_5$ be independent, each with uniform distribution on $(0, 1).$ Let $R$ be the distance between the minimum and maximum of the $U_i^{'}$s.


*

*Find the joint density of the max and the min of the $U_i^{'}$s 

*Find $E(R)$

*Find $P(R>0.5)$
For 1) and 2), I think I can just apply the formula to get $$U_{1}=5(1-x)^{4} \ \text{and} \   U_{5}=5x^{4}$$ because they are independent, so the joint density is the product $$25x^4(1-x)^{4}$$ and by expectation formula $$E(R)=E(U_{5})-E(U_{1})=2/3$$
However, I have no idea how to deal with the third problem. Any help? Thanks.
 A: Let $\mathcal{U}_n=\{U_1, \ldots, U_n\}$ be a collection of iid random variables. Denote $U_{1:n} = \min \mathcal{U}_n$ and $U_{n:n} = \max \mathcal{U}_n$ be the smallest and the largest of the collection.
Then
$$\begin{eqnarray}
   F_{U_{1:n},U_{n:n}}\left(u_1, u_n\right) &=& \Pr\left(U_{1:n} \leqslant u_1, U_{n:n} \leqslant u_n\right) \\&=& \Pr\left(U_{n:n} \leqslant u_n\right) - \Pr\left(U_{1:n} > u_1, U_{n:n} \leqslant u_n\right) 
\end{eqnarray}
$$
Now, since 
$$
   \{U_{n:n} \leqslant u_n\} = \{\max \mathcal{U}_n \leqslant u_n\}  \equiv \{ U_1 \leqslant u_n, U_2 \leqslant u_n, \ldots, U_{n} \leqslant u_n \}
$$
and
$$
  \{U_{1:n} > u_1\} \equiv \{ U_1 > u_1, U_2 > u_1, \ldots, U_n > u_1 \}
$$
We have,
$$
   F_{U_{1:n},U_{n:n}}\left(u_1, u_n\right) = F_U\left(u_n\right)^n - \left(F_U\left(\max(u_n,u_1)\right)-F_U\left(\min(u_1,u_n)\right))\right)^n
$$
Differentiating, and assuming $0 < u_1 < u_n <1$:
$$
  f_{U_{1:n},U_{n:n}}\left(u_1, u_n\right) = n(n-1) \left(F_U\left(u_n\right)-F_U\left(u_1\right))\right)^{n-1} f_U(u_n) f_U(u_1) = n (n-1) \left(u_n-u_1\right)^{n-2}
$$
The expected value of $R=U_{n:n}-U_{1:n}$
$$
  \mathbb{E}\left(R\right) = \int_{0}^{1} \mathrm{d}u_n \int_0^{u_n} \mathrm{d}u_1 n \left(n-1\right) \left(u_n-u_1\right)^{n-1} = \frac{n-1}{n+1} 
$$
Similarly we can compute $\Pr\left(R > \frac{1}{2}\right)$:
$$\begin{eqnarray}
  \Pr(R > 1/2) &=& \Pr\left(u_1 < u_n - \frac{1}{2} \right) \\ &=& \int_{1/2}^{1} \mathrm{d}u_n \int_0^{u_n-1/2} \mathrm{d}u_1 n \left(n-1\right) \left(u_n-u_1\right)^{n-1} \\ &=& \int_{1/2}^{1} \mathrm{d}u_n n \left(u_n^{n-1} - \left(\frac{1}{2}\right)^{n-1} \right) \\ &=& 1 - \frac{n+1}{2^n}
\end{eqnarray}
$$
Confirming with Mathematica:
In[6]:= Probability[
  un - u1 > 1/2, {u1, un} \[Distributed] 
   OrderDistribution[{UniformDistribution[], n}, {1, 
     n}]] // FullSimplify

Out[6]= 1 - 2^-n (1 + n)

In[7]:= Expectation[
  un - u1, {u1, un} \[Distributed] 
   OrderDistribution[{UniformDistribution[], n}, {1, 
     n}]] // FullSimplify

Out[7]= (-1 + n)/(1 + n)

A: General approach for such a problem: There should be a formula in the relevant chapter that allows
you to find the joint distribution of the max and the min.
Transform to get the sum (twice the midrange) and difference (range).
Integrate to find the density of the range. These formulas appear
simple for uniform random variables, but be careful of the limits
of integration.
Addendum: It is always nice to have an idea what some of the answers might be,
and the following simple simulation in R is helpful in that regard.
 m = 10^6;  n = 5;  x = runif(m*n);  MAT = matrix(x, nrow=m)
 mn = apply(MAT, 1, min);  mx = apply(MAT, 1, max);  rg = mx - mn
 mean(rg > .5)
 ## 0.812145  # approx
 mean(rg)
 ## 0.666553  # approx
 hist(rg, prob=T);  curve(dbeta(x, 4, 2), add=T)  # PDF guessed from hist
 1 - pbeta(.5, 4, 2)
 ## 0.8125

