# Why does this algorithm give the Beta distribution in the limit (considering length of intervals between two random variables)?

Consider the following algorithm:

1. In the $n$th iteration, take two random variables uniform on $[0,1]$. Define the smaller as $X_1^{(n)},$ the bigger as $X_2^{(n)}$ and the interval between them as $I_n=\left[X_1^{(n)},X_2^{(n)}\right]$.
2. Define $D_n(x)=c_n\sum_{k=1}^n \mathbf{1}_{I_k}(x)$ with $D_0(x)=0$, where $\mathbf{1}_{I_k}(x)$ is the Indicator function, and where $c_n$ is a normalization constant.

(See the edit at the bottom if this is still not clear.)

The question is now what $D(x)=\lim_{n\rightarrow \infty}[D_n(x)]$ is?

I solved it like this (I thought of it as sums first):

\begin{align} D(x)&=c\int_0^{x}\int_{x}^1(y'-x')\;\mathrm{d}y'\mathrm{d}x' \\ &=c\int_0^{x}\left(\frac{1}{2}-x'-\frac{1}{2}x^2+xx'\right) \mathrm{d}x'\\ &= cx(1-x)\\ &=6x(1-x), \end{align} where $c$ is a normalization constant, and $x'$ and $y'$ represents $X_1$ and $X_2$, respectively.

What I did (speaking in terms of the discrete case) was to calculate the sum of the lengths of all intervals that included $x$. These intervals are $[x',x],[x',x+dy'],\cdots,[x',1-dy'],[x',1]$ for all $x'\in[0,x]$, hence the limits on the integrals.

But lo and behold, this is the Beta distribution with $\alpha=\beta=2$!

Q$_1$: Why is the Beta distribution the answer here? I'm looking for an informal connection here (something along the lines of "well, you can view $D(x)$ as the probability of ___, the solution of which is well-known to be given by the Beta distribution" or whatever the connection might be). I tried reading the applications section of the wiki, but couldn't find anything that might apply and generalize the problem described above (most of the section went over my head, so please forgive me if there is an obvious connection).

Q$_2$: I'm sorry if this sounds pretentious, but has this angle (considering intervals between two random variables) been used to arrive at this Beta distribution before? It probably has, but I'd be curious to see the context.

Thanks.

Edit (an example of the algorithm):

At first, $D_0(x)=0$. Let's say that $I_1=[0.1,0.4]$. Then $$D_1(x)=c_1\cases{1 \quad 0.1\leq x \leq 0.4 \\ 0 \quad \text{otherwise}}$$ with $c_1=\frac{10}{3}$. Now let's imagine that $I_2=[0,0.2]$. Then we would have $$D_2(x)=c_2\cases{1 \quad 0.1< x \\ 2 \quad 0.1\leq x < 0.2 \\1 \quad 0.2\leq x \leq 0.4 \\ 0 \quad \text{otherwise}}$$ with $c_2=\frac{7}{10}$.

• As per a request from the OP; this conversation has been moved to chat. Sep 1, 2016 at 8:23
• The sequence $(\mathbf 1_{I_k}(x))_k$ is i.i.d. with mean $m(x)=P(X_1<x<X_2)$. To compute $m(x)$, consider two i.i.d. random variables $U$ and $V$ uniform on $(0,1)$ and note that $m(x)=P(U<x<V)+P(V<x<U)$, which, by independence, is $m(x)=P(U<x)P(x<V)+P(V<x)P(x<U)$, hence $$m(x)=2x(1-x)$$ Now, the SLLN shows that $$\frac1n\sum_{k=1}^n\mathbf 1_{I_k}(x)\to m(x)$$ almost surely, when $n\to\infty$. Re the interpretation of this result, the link between order statistics and beta distributions is well known.
– Did
Sep 1, 2016 at 8:30