# Distribution of interval that contains N independent variables

N independent random variables are uniformly distributed on [0,1]. What is the distribution function of length of minimal interval that contains all of them?

• Just to clarify, are you asking for the distribution of (the highest variable minus the lowest variable = max-min)? – Varun Vejalla Jul 21 '19 at 21:45
• Yes, this is what I mean – Al.1 Jul 21 '19 at 22:38
• From this result you can deduce that your answer is $$\frac{N-1}{N+1}$$ – Crostul Jul 21 '19 at 22:48
• @Crostul OP wanted the distribution, not the expected value. – Varun Vejalla Jul 21 '19 at 23:50

For $$X_1,\ldots,X_n\in\mathcal{U}(0,1)$$, let $$M=\max\limits_{1\leqslant k\leqslant n}X_k$$ and $$W=\min\limits_{1\leqslant k\leqslant n}X_k$$. Then $$\mathbb{P}(M-W\leqslant t)=\color{blue}{nt^{n-1}-(n-1)t^n}\qquad(0\leqslant t\leqslant 1)$$
There is a number of ways to prove it. Here's a simple geometric argument: this probability is equal to the volume (i.e., measure) of the set $$\left\{(x_1,\ldots,x_n)\in[0,1]^n\ \middle|\ \max_{1\leqslant k\leqslant n}x_k-\min_{1\leqslant k\leqslant n}x_k\leqslant t\right\}=\bigcup_{a\in[0,1-t]}[a,a+t]^n$$ which is a "running cube" with side $$t$$, and its measure equals the measure of the cube (equal to $$t^n$$) plus the measure of "traces" of its $$n$$ faces (each is an oblique parallelepiped, of height $$1-t$$, and therefore of measure $$t^{n-1}\cdot(1-t)$$).
A direct approach (which also works more generally) is to find the joint distribution of $$(M,W)$$. We clearly have $$\mathbb{P}(M\leqslant m,W\geqslant w)=\prod_{k=1}^{n}\mathbb{P}(w\leqslant X_k\leqslant m)=(m-w)^n$$ for $$0\leqslant w\leqslant m\leqslant 1$$. This gives, for $$n>1$$, the density $$p_{M,W}(m,w)=-\frac{\partial^2}{\partial m\,\partial w}\mathbb{P}(M\leqslant m,W\geqslant w)=n(n-1)(m-w)^{n-2},$$ and, finally, the required probability \begin{align}\mathbb{P}(M-W\leqslant t)&=\iint\limits_{\substack{0\leqslant w\leqslant m\leqslant 1\\m-w\leqslant t}}p_{M,W}(m,w)\,dm\,dw\\&=n(n-1)\int_0^1\int_{w}^{\min\{w+t,1\}}(m-w)^{n-2}\,dm\,dw\\&=n\int_0^1\min\{t,1-w\}^{n-1}\,dw\quad\color{gray}{\left[=\int_0^{1-t}+\int_{1-t}^1\right]}\\&=nt^{n-1}(1-t)+t^n=nt^{n-1}-(n-1)t^n.\end{align}