Correlation of uniform variables Let $X$ and $Y$ be independent random variables, $X,Y \sim unif(0,1)$. Let $U = \min \{X,Y\}$ and $V = \max\{X,Y\}$. Find the correlation coefficient of $U$ and $V$.
I think we can assume that $U = X$ and $V = Y$ because they both have the same distribution. Further, $E[U] = E[V] = 1/2$ and $Var(U) = Var(V) = 1/12$. Next is $E[UV]$ and this is where I am stuck, because I can't solve this $E[UV] = \int_{}^{}\int_{\mathbb{R}^2}^{}uvf(u,v)dudv$. I think I can substitute $f(u,v)$ with $1$, but I'm not sure.
 A: This problem has several nice shortcuts.
For the first term, you can note that $UV=XY$. This is because one or the other of $X,Y$ is the smaller one and the other is the larger, and multiplication doesn't care what order they come in. So since $ X, Y $ are independent, $ E [UV]= E [X] E [Y] = 1/4$.
We can use a similar trick to calculate $E[U]$ and $E[V]$. Let's think about $U$. We first consider $X=x$. Now with probability $1-x$, $Y>x$, in which case $U=x$. With probability $x$, $Y \leq x$, in which case $U$ is uniform on $[0,x]$. I'll write $U_x$ for a uniform variable on $[0,x]$. Now linearity of expectation tells us that:
$$E[U|X=x]=x (1-x) + x E[U_x]=x (1-x) + x^2/2$$
Now the total expectation formula gives:
$$E[U]=\int_0^1 E[U|X=x] f_X(x) dx = \int_0^1 (x (1-x) + x^2/2) dx.$$
The situation is similar to calculate $E[V]$, $E[U^2]$, and $E[V]^2$, then you can just combine everything to get the correlation coefficient.
A: Let's find the joint distribution.  When $u \leq v$ then 
\begin{align*}
P(U<u,V<v)&=P(\min\{X,Y\}<u,\max\{X,Y\}<v)\\
&=P(X<u,Y<u)+P(X<u,u<Y<v)+P(u<X<v,Y<u)\\
&=P(X<u)P(Y<u)+P(X<u)P(u<Y<v)+P(u<X<v)P(Y<u)\\
&=u^2+2u(v-u)=2uv-u^2 
\end{align*}
When $v<u$ then
\begin{align*}
P(U<u,V<v)&=P(\min\{X,Y\}<u,\max\{X,Y\}<v)=v^2
\end{align*}
Hence $f(u,v)=2$ when $u \leq v$ and $f(u,v)=0$ when $v<u$. Then $f(v)=2v$, $f(u)=2(1-u)$. Then $E[U]=1/3$, $E[U^2]=1/6$, $E[V]=2/3$,  $E[V^2]=1/2$ and 
$$E[UV]=\int_0^1\int_0^{1}uv f(u,v)dudv
=2\int_0^1\int_0^{v}uv dudv
=\int_0^1v^3 dv=\frac{1}{4}$$
Now using this, I get the correlation is $1/2$.
btw. More generally if $X$ and $Y$ are independent and have distributions $F_x$ and $F_y$. Then when $u \leq v$,
\begin{align*}
P(U<u,V<v)&=P(\min\{X,Y\}<u,\max\{X,Y\}<v)\\
&=F_x(u)F_y(u)+F_x(u)(F_y(v)-F_y(u))
+F_y(u)(F_x(v)-F_x(u))\\
&=F_x(v)F_y(u)+F_x(u)F_y(v)-F_x(u)F_y(u)
\end{align*}
and when $v<u$,
$$
P(U<u,V<v)=P(\min\{X,Y\}<u,\max\{X,Y\}<v)=F_x(v)F_y(v)
$$
so $f(v,u)=f_x(v)f_y(u)+f_x(u)f_y(v)$ when $u \leq v$ and $f(v,u)=0$ when $v<u$. Using this you can calculate $E[g(U,V)]$ for any function $g$.
A: You can also check whether your answer is correct using a computer algebra system. In this instance, since $X$ and $Y$ are independent standard Uniform random variables, their joint pdf, say $f(x,y)$ is:
f = 1;   domain[f] = {{x, 0, 1}, {y, 0, 1}};

Then, you seek:
Corr[{Min[x, y], Max[x, y]}, f]

$\frac12$
where I am using here the Corr function from the mathStatica package for Mathematica. As disclosure, I should perhaps add that I am one of the authors.
The expectation you are having trouble with is $E[U V]$:
Expect[Min[x, y] Max[x, y], f]

$\frac14$
Also, your calculation $E[U] = E[V] = 1/2$ is plainly wrong:  this should be obvious since $E[X] = \frac12$, so $E[min[X,Y]]$ must be less than $\frac12$.
