# Probability that $\max(X_1, \ldots, X_n) - \min(X_1, \ldots, X_n) \leq 0.5$

Consider $$n$$ IID random variables $$X_1, \ldots, X_n \sim U(0,1)$$. What is the probability that $$\max(X_1, \ldots, X_n) - \min(X_1, \ldots, X_n) \leq 0.5$$.

Denote $$Z_1, Z_n$$ as the min and max respectively. Then by symmetry, I believe $$E[Z_1] = 1 - E[Z_n]$$. I am unsure how to find $$P(Z_n - Z_1 \leq 0.5)$$. I think I can find the distribution for $$P(Z_n), P(Z_1)$$ individually, how how do I go about finding the distribution of the difference between the 2?

## 3 Answers

I think you're coming at this from a slightly wrong direction; importantly, $$Z_1$$ and $$Z_n$$ aren't independent so knowing their individual distributions doesn't help you. For instance, in the $$n=2$$ case, $$Z_1\geq \frac12$$ with probability $$\frac14$$ and with the same probability $$Z_2\leq \frac12$$, but these two events can never happen simultaneously.

Instead, suppose that $$Z_1=z$$. Then all of the other $$X_i$$ are equidistributed in $$[z, 1]$$ (why?). So your probability for this value of $$Z_1$$ is simply $$\displaystyle\prod_{i, X_i\neq Z_1} P\left(X_i \leq \min(1, z+0.5) | z\leq X_i\right)$$. And since the $$X_i$$ are independent, this is just $$\displaystyle\left(P\left(X_i \leq \min(1, z+0.5) | z\leq X_i\right)\right)^{n-1}$$. Then you'll have to integrate this over the distribution of $$Z_1$$ (which you should be able to find with a sort of symmetry argument.)

• Quick question before I read this in more detail but why is the left end not inclusive of $z$? Couldn't you have $X_i, X_j, i \neq j$ such that $X_i, X_j = z$? Or is this not possible to have the same realization because the domain is continuous? – David Jul 22 '20 at 0:53
• @David Fortunately, whether it's inclusive or not doesn't really matter; it's a probability 0 event. If, say, the $X_i$ were integers uniformly distributed on $[1,m]$ for some $m$ then that becomes a bit more relevant. That said, you're right (especially since I use $\leq$ below) and I'll fix that interval. – Steven Stadnicki Jul 22 '20 at 0:55
• Since we're conditioning on $z \leq X_i$, does this mean the pdf for $X_i$ is is $\frac{1}{1-z}$ instead of $1$? – David Jul 22 '20 at 1:00
• @David Exactly so. – Steven Stadnicki Jul 22 '20 at 2:32

Let $$A = 1-\min(X_1,\ldots,X_n)$$ and $$B = \max(X_1,\ldots,X_n)$$. The joint CDF of $$A,B$$ is given by:

\begin{align*} F(a,b) &= P\{A \le a, B \le b\} \\ &= P\{\min(X_1,\ldots,X_n) \ge 1-a \ \text{and} \ \max(X_1,\ldots,X_n) \le b\} \\ &= P\{1-a \le X_k \le b \ \text{for} \ k = 1,\ldots,n\} \\ &= \prod_{k = 1}^{n}P\{1-a \le X_k \le b\} \\ &= \prod_{k = 1}^{n}(b-(1-a))I(b \ge 1-a) \\ &= (b-(1-a))^nI(b \ge 1-a) \end{align*}

for $$0 \le a,b \le 1$$.

The joint PDF of $$A,B$$ can be found by computing $$f(a,b) = \dfrac{\partial^2F}{\partial a \partial b}(a,b)$$, and then you can compute $$P\{\max(X_1,\ldots,X_n)-\min(X_1,\ldots,X_n) \le \tfrac{1}{2}\} = P\{B-(1-A) \le \tfrac{1}{2}\}$$ by integrating $$f(a,b)$$ over the appropriate subset of $$[0,1] \times [0,1]$$.

• $E[A] = E[B]$ here right? (just want to confirm my earlier intuition in the OP which isn't super relevant) – David Jul 22 '20 at 1:01
• Yes. In fact, $A$ and $B$ are identically distributed, although not independent. – JimmyK4542 Jul 22 '20 at 1:03
• Why is the indicator variable needed here? Isn't $b \geq 1-a$ by definition? – David Jul 22 '20 at 1:08
• You can also just consider the domain of $F(a,b)$ to be $(a,b)$ such that $b \ge 1-a$ and $0 \le a \le 1$ and $0 \le b \le 1$, and then you can ignore the indicator function. – JimmyK4542 Jul 22 '20 at 1:10
• Ah I see, so in your current answer, you aren't necessarily assuming that $b \geq 1-a$? – David Jul 22 '20 at 1:15

Let $$Z_n$$ equal the maximum, and $$Z_1$$ the minimum of $${\{X_k\}}_{k\in\{1..n\}}$$, which is a sample of $$n$$ iid random variables with probability density function $$f_{\small X}(x)$$ and cummulative distribution function $$F_{\small X}(x)$$.

\begin{align}f_{\small X}(x)&=\mathbf 1_{x\in(0..1)}\\[2ex]F_{\small X}(x)&=x\mathbf 1_{x\in(0..1)}+\mathbf 1_{x\in[1..\infty)}\end{align}

Then we find

\begin{align}f_{\small Z_1,Z_n}(s,t) &= \dfrac{n!}{\,1!\,(n-2)!\,1!\,} f_{\small X}(s)\bigl(F_{\small X}(t)-F_{\small X}(s)\bigr)^{n-2}f_{\small X}(t)\mathbf 1_{0\leq s\leq t\leq 1}\\[1ex]&=n(n-1)(t-s)^{n-1}\mathbf 1_{0\leq s\leq t\leq 1}\\[2ex]f_{\small (Z_n-Z_1)}(z)&=\int_0^{1-z} f_{\small Z_1,Z_2}(s,s+z)~\mathrm ds\\[2ex]F_{\small (Z_n-Z_1)}(z)&=\int_0^z f_{\small (Z_n-Z_1)}(u)~\mathrm d u\\[1ex]&= n(n-1)\int_0^{z}\int_0^{1-u} u^{n-1}~\mathrm d s~\mathrm d u\end{align}

$$\mathsf P(Z_n-Z_1\leqslant 0.5)=F_{\small (Z_n-Z_1)}(0.5)$$ of course.   It comes out to a rather tidy expression. $$\phantom{F_{\small (Z_n-Z_1)}(0.5)=(n+1)0.5^{n}}$$