Let $U_i$ be i.i.d Uniform(0,1) random variables, and let $X_{(1)},\dotsb, X_{(n)}$ the order statistics of the random variables. Then find distribution of $Y = U_{(n)} - U_{(1)}$.
I used two methods to solve this problem.
- Using joint pdf of order statistics
we know pdf of $(X_{(r)},X_{(s)})^t$ $(1 \leq r<s \leq n)$ is
$f_{X_{(r)},X_{(s)}} (x,y) = {n! \over {(r-1)!(s-1-r)! (n-s)!}}[F(x)]^{r-1}[F(y)-F(x)]^{s-1-r}[1-F(y)]^{n-s}f(x)f(y)$
So, $f_{X_{(1)},X_{(n)}}(u_1,u_n) = {n! \over {(n-2)!}}(u_n - u_1)^{n-2} I_{(0<u_1<u_n<1)}$
Let $X \equiv X_{(1)}$ and $u : \begin{cases}X = X_{(1)}\\Y = X_{(n)} - X_{(1)}\end{cases}$, $u^{-1} :\begin{cases}x_{(1)} = x\\x_{(n)} = x+y\end{cases}$ , u : one to one , $\vert det( {\partial(x_{(1)},x_{(n)}) \over {\partial (x,y)}}) \vert = 1$
$\therefore f_{X,Y}(x,y) =f_{X_{(1)},X_{(n)}}(u_1,u_n)\vert det( {\partial(x_{(1)},x_{(n)}) \over {\partial (x,y)}}) \vert = n(n-1)y^{n-2} I_{(0,1)}(x) I_{(0,1)}(y)$
$\therefore f_Y(y) = \int_{0}^{1} f_{X,Y}(x,y) dx = n(n-1)y^{n-2} I_{(0,1)}(y)$
- Using Beta distribution
We know $X_{(r)} \sim Beta(r,n-r+1)$
So, $X_{(n)} \sim Beta(n,1),X_{(1)} \sim Beta(1,n),Y = X_{(n)} - X_{(1)} \sim Beta(n-1,2)$
$\therefore f_{Y}(y) = {\Gamma(n+1) \over {\Gamma(n-1) \Gamma(2)}} y^{n-2} (1-y) I_{(0,1)}(y) $
I don't understand why the results of these methods are different. I don't know where I got it wrong, can you help me please?