# Maximum of uniformly distributed random variables using iterated expectations

I'm working through the problems in Wasserman's 'All of Statistics'. The chapter on expectations and conditional expectations ends with a (seemingly) easy problem:

Let $Y$ be the maximum of $n$ iid uniformly distributed rvs on $(0,1)$. What is $\mathbb{E}(Y)$?

I determined this using conditional expectations but having checked against answers on the site there must be a fault in my reasoning. Can someone please tell me where my fault was?

Suppose $n$ = 2, and the r.v.'s be $X_1, X_2$. For any draw, one will be the larger and one smaller. Let us denote them by $\max(X_1, X_2) = m$ And $\min(X_1, X_2) = l$ The problem should reduce to finding $\mathbb{E}(m)$.

By the Law of Iterated Expectations, $\mathbb{E}(m) = \mathbb{E}(\mathbb{E}(m|l))$.

Which would be $$\int_0^1 [\int_l^1 [m.f(m|l)] \text{d}m f(l)] \text{d}l$$

$f(m|l)$ should be $\frac 1 {1 - l}$.

$f(l)$ is simply the uniform pdf so is 1.

Therefore the expression to compute should be

$$\int_0^1 [\int_l^1 [m.\frac 1 {1 - l}] \text{d}m] \text{d}l$$

$$= \int_0^1 [\frac {m^2} {2(1-l)}]^1_l \text{d}l$$

$$= \int_0^1 [\frac {1+l} 2] \text{d}l$$

$$= [\frac {l} {2}+\frac {l^2} {4} ]_0^1$$

$$= \frac 3 4$$

Furthermore one can generalise to $1 - \frac 1 {2^n}$.

This is incorrect, as has been demonstrated by numerous other excellent answers the solution should $\frac n {n + 1}$.

What have I gotten wrong here?

• How did you obtain $3/4$?
– whuber
Commented Dec 23, 2014 at 2:09
• we need more details on how you derive $f(m|l)$ and $f(l)$. In fact this approach seems far from the best approach since, once you are able to determine $f(l)$ you should also be able to determine $f(m)$ by symmetry. Commented Dec 23, 2014 at 8:20
• I have elaborated on the computation to demonstrate. @Xi'an, I know this probably isn't the best method, I am more concerned about what exactly I am doing wrong in the general reasoning. Commented Dec 23, 2014 at 15:14
• Both $f(m|l)$ and $f(l)$ are wrong in your formulas: when you consider the largest and smallest observations among uniforms they are no longer uniform! Commented Dec 23, 2014 at 15:16
• Take $(X_1,X_2)$ as uniforms and from there derive $f(l)$. Commented Dec 23, 2014 at 15:17

The probability that the maximum $Z$ of $n$ independent $U(0,1)$ random variables is no larger than $z$, $0 < z < 1$ is simply $\prod P\{X_i \leq z\} = z^n$ and so the density is $nz^{n-1}\mathbf 1_{0 < z < 1}$. From this, it is easy to verify that $$E[Z] = \int_0^1 z\cdot nz^{n-1}\,\mathrm dz = \left.\frac{n}{n+1}z^{n+1}\right|_0^1 = \frac{n}{n+1}.$$
If you want to do it the hard way by first computing $E[Z\mid W]$ first (where $W$ is the minimum of the $n$ random variables), then we need to find the conditional distribution of $Z$ given $W = w$. Let us start by first finding the joint distribution of $(Z,W)$. For $0 < w < z < 1$, we have that $$P\{z< Z < z+\Delta z, w < W < w+\Delta w\} \approx f_{Z,W}(z,w)\cdot\Delta z \Delta w.$$ Any of the $n$ $X_i$ can be $Z$ and any one of the remaining $n-1$ $X_j$ can be $W$, and the remaining $n-2$ random variables must be in the interval $[w,z]$. Thus we have \begin{align} f_{Z,W}(z,w) &= n(n-1)(z-w)^{n-2}, 0 < w < z < 1,\\ f_W(w) &= \int_w^1 n(n-1)(z-w)^{n-2}\,\mathrm dz\\ &= n (z-w)^{n-1}\bigr|_w^1\\ &= n\left(1-w\right)^{n-1},\\ f_{Z\mid W}(z\mid W=w) &= \frac{n-1}{(1-w)^{n-1}}(z-w)^{n-2}, ~ w < z < 1.\\ E[(Z -W) \mid W =w] &= \int_w^1 (z-w)\cdot \frac{n-1}{(1-w)^{n-1}}(z-w)^{n-2},\mathrm dz\\ &= \frac{n-1}{n}(1-w),\\ E[Z\mid W = w] &= w + \frac{n-1}{n}(1-w), \end{align} so that we arrive at $E[Z\mid W] = \frac{W + n-1}{n}$. We finally get to use the law of iterated expectation to arrive at $$E[Z] = E[E[Z\mid W]] = E\left[\frac{W + n-1}{n}\right] = \frac{\frac{1}{n+1} + n-1}{n} = \frac{n}{n+1}$$ if you remember that $E[W] = \frac{1}{n+1}$. If not, work it out from the density of $W$ given above (hint: it is a Beta density).