Generate three random numbers independently and uniformly distributed in $(0,1)$. Let $X$ be the smallest of these three numbers and $Y$ the biggest.
(a) Do you expect $X$ and $Y$ are positively correlated, negatively correlated, or uncorrelated? Explain your reasoning intuitively then find the value of the correlation coefficient $\rho(X,Y)$.
(b) Suppose $n$ (as opposed to three) random numbers are generated. Compute the correlation coefficient $\rho(X,Y)$.
Answer: Am I correct in assuming that $X$ and $Y$ are uncorrelated because they are independent, and thus $\rho(X,Y)$ is 0 in both cases?
Totally wrong!
Define $U,V$ two independend rv's form Uniform distribution in $[0;1]$
$X$ and $Y$ are not independent but positively correlated. In fact the value of $Y=max(U,V)$ depends on the values of $X$.
If, as an example $X=0.7$ the values of Y are not anymore in $[0;1]$ but greater than 0.7.
Easy example: just as an hint, suppose we generate only 2 random numbers independently, say $U,V$.
Set $X=min(U;V)$ and $Y=max(U;V)$
The correlation between $X$ and $Y$ can be misured with their covariance
$$Cov(X,Y)=E(XY)-E(X)E(Y)=E(UV)-E(X)E(Y)=\frac{1}{2}\cdot\frac{1}{2}-\frac{1}{3}\frac{2}{3}=\frac{1}{36}$$
skipping for a moment case a), for the general case b), after some calculations based on Order Statistics, the covariance results to me
$$Cov(X;Y)=\frac{1}{(n+1)^2(n+2)}$$
Which, for $n=2$ results exactly $\frac{1}{36}$ as derived before and $\frac{1}{80}$ for case a), when $n=3$
This means, as intuitive it is, that the greater is $n$ the lower is the linear dependence between Max and min.
If you want,as requested, you can easy calculate also $\rho(X,Y)$ but covariance is enough to capture linear dependence between the rv's
How to derive the general solution (sketch)
By definition,
$$Cov(X,Y)=\mathbb{E}[XY]-\mathbb{E}[X]\mathbb{E}[Y]$$
$\mathbb{E}[X]$ and $\mathbb{E}[Y]$ are very easy to calculate using the distribution of min and max, obtaining respectively $\frac{1}{n+1}$ and $\frac{n}{n+1}$
The hardest probelm is to calculate $\mathbb{E}[XY]$. To solve it I used the definition of density of order statistics that you can find in the link above.
$$f_{XY}(x,y)=n(n-1)(y-x)^{n-2}$$
where $x<y$
Thus
$$\mathbb{E}[XY]=\int_0^1 n xdx\Bigg[\int_x^1 (n-1)y(y-x)^{n-2}dy \Bigg]dx=\dots=\frac{1}{n+1}-\frac{1}{(n+1)(n+2)}$$
When solving the integral, you will arrive at the following
$$\mathbb{E}[XY]=n\int_0^1 x(1-x)^{n-1}dx-\int_0^1 x(1-x)^{n}dx=n\frac{\Gamma(2)\Gamma(n)}{\Gamma(n+2)}-\frac{\Gamma(2)\Gamma(n+1)}{\Gamma(n+3)}=$$
$$=\frac{n(n-1)!}{(n+1)!}-\frac{n!}{(n+2)!}=\frac{1}{n+1}-\frac{1}{(n+2)(n+1)}$$
This results follow using Beta Function