# Density and expectation of the range of a sample of uniform random variables

If the variables $\alpha_1$...$\alpha_n$ are distributed uniformly in $(0,1)$,

1. How do I show that the spread $\alpha_{(n)}$ - $\alpha_{(1)}$ has density $n (n-1) x^{n-2} (1-x)$ and expectation $(n-1)/(n+1)$?
2. What is the probability that all $n$ points lie within an interval of length $t$?
-
Homework? What have you tried? Where are you stuck? – cardinal Apr 19 '11 at 3:40
I'm merging your duplicate accounts. Please consider registering so the software can keep track of who you are. – Willie Wong Apr 19 '11 at 14:39

Here's a hint: The answer to part 2 is quite easy. And if you consider it, you might see a trick on how to get the answer to part 1.

-
I understand, I think that if I can find P(Xn - X1 < t), which is P(Xn < X1 + t), then I will have the distribution for Xn - X1 and will then be able to show the density and the expectation. But I'm not exactly sure how to get there. – user9767 Apr 19 '11 at 4:14
Alright, I took the integral of n(n-1)x^(n-2)(1-x) with respect to x from o to t and got the answer nt^(n-1) - (n-1)t^n as the probability. still am not seeing part 1, however – user9767 Apr 19 '11 at 4:32

This is a (straight forward?) exercise is order statistics.

From Wikipedia, the pdf for the joint order statistic is:

$$f_{ X_{(i)}, X_{(j)} }(u, v) =$$ $$\frac{ n! }{ (i-1)! (j-1-i)! (n-j)! } [ F_X(u) ]^{j-1} [F_X(v) - F_X(u)]^{j-1-i} [1 - F_X(v)]^{n-k} f_X(u) f_X(v)$$

Where $F_X(u)$ is the cumulative distribution function (or cdf) and $f_X(u)$ is the probability density function (or pdf) of the random variable $X$.

Plugging in $i=1$ and $j=n$ with $X = \alpha$, $f_{\alpha}(u) = 1$ and $F_{\alpha}(u) = u$, we get:

$$f_{ \alpha_{(1)}, \alpha_{(n)} }(s, s+t) = \frac{ n! }{ (n-2)! } [ s+t - s ]^{n-2} = n (n-1) t^{n-2}$$

for a starting point $s \in [0, 1-t]$ with interval length $t$. To find the probability of finding $\alpha_{(1)}$ and $\alpha_{(n)}$ within some interval of $t$, we need to integrate over all (permissible) starting positions, $s$:

$$\int_0^{1-t} f_{\alpha_{(1)},\alpha_{(n)}}(s, s+t) ds = \int_{0}^{1-t} n (n-1) t^{n-2} ds = n (n-1) t^{n-2} \int_0^{1-t} ds$$ $$= n (n-1) t^{n-2} (1-t)$$

Which gives the first part of the answer for question 1. For the second part to question 1, you could integrate the above equation for $t \in [0, 1]$ or you could just take the expectation of the difference of the random variable $\alpha_{(n)}$ with $\alpha_{(1)}$. I will do the latter. The pdf of the $k$'th order statistic is:

$$f_{X_{(k)}}(u) = \frac{ n! }{ (k-1)! (n-k)! } [F_X(u)]^{k-1} [1-F_X(u)]^{n-k} f_X(u)$$

and plugging in $X = \alpha$, $k=1$ and $k=n$ for the 1st and $n$'th order statistic (of the uniform distribution) respectively, we get:

$$f_{\alpha_{(1)}}(u) = n (1 - u)^{n-1}$$ $$f_{\alpha_{(n)}}(u) = n u^{n-1}$$

and taking the expectation of their difference:

$$E[ \alpha_{(n)} - \alpha_{(1)} ] = \int_{0}^{1} u (n u^{n-1} - n (1 - u)^{n-1} ) du = \frac{n}{n+1} - \frac{1}{n+1} = \frac{n-1}{n+1}$$

As desired. (note that $\alpha_{(n)}$ and $\alpha_{(1)}$ are not independent but that the expectation of the sums of random variables is still the same regardless).

To answer part 2, one must find $\Pr\{ \alpha_{(n)} - \alpha_{(1)} \le t \}$. We just derived the pdf of the joint distribution that the difference of $\alpha_{(n)}$ and $\alpha_{(1)}$ is of length $t$, so now we just have to sum over all lengths less than $t$:

$$\int_0^{t} n (n-1) x^{n-2} (1-x) dx = t^{n-1} ( n - (n-1) t)$$

I must admit that I just looked up the pdf of the joint order statistic. Could anyone tell me (or give a reference) on how to derive this equation?

-
The derivation of the joint density of order statistics is as follows: we want the probability that $U_{(i)}$ is in some small interval $[u, u + du]$ and $U_{(j)}$ is in some small interval $[v, v + dv]$. This amounts to finding the probability that $i-1$ of $U_1, \ldots, U_n$ is less than $u$, one is in $[u, u + du]$, $j-i-1$ are between $u+du$ and $v$, one is in $[v, v + dv]$, and the remaining $n-j$ are greater than $v$. The five clauses of the previous sentence give the five factors; the embedded combinatorial problem gives the premultiplying factor. – Michael Lugo Apr 20 '11 at 2:23
@Michael, Thanks. Obvious in retrospect. – user4143 Apr 20 '11 at 4:08