Covariance of a uniform distribution

1.6k Views Asked by At

I have the following problem:

The variables $X$ and $Y$ have the joint probability: $f(x,y)=2 $ for $0 \le y \le x \le 1$. What is the covariance between $X$ and $Y$?

The answer is 1/36

I know that $\operatorname{Cov}(x,y) = E[XY] - E[X]E[Y]$

First I calculated the marginal PDFs since it was the first part of the question.

$f_x(x)=2x $ and $f_y(y) = 2(1-y)$

To calculate $E[X], E[Y]$ I need to multiply with $x$ and $y$ and integrate. Do I need to integrate for both $x$ and $y$ from 0 to 1? If not what will be the integration boundaries?

How do I calculate $E[XY]$? I tried with the following integral:

$$\int_0^{1} \int_0^{x} (2xy) \mathrm{d}y \mathrm{d}x$$

But I'm not sure if this is correct, since I don't get the right answer.

4

There are 4 best solutions below

2
On BEST ANSWER

You could use the expression $Cov(X,Y)=E((X-\mu_X)(Y-\mu_Y))$ instead. Since you have the marginals, $\mu_X$ and $\mu_Y$ should be easy to compute.

2
On

Your marginals are right. To calculate $E[X]$, $E[Y]$ you compute

$$E[X]=\int_0^1 xf_x(x) \, dx = \int_0^1 2x\cdot x \, dx = \left. \frac{2x^3}{3} \right|_0^1 = \frac{2}{3}$$ and $$E[Y]=\int_0^1 yf_y(y) \, dy = \int_0^1 2(1-y)\cdot y \, dy = \left[ y^2 - \frac{2y^3}{3}\right|_0^1 = \frac{1}{3}.$$

For the double integral expression for $E[XY]$ (which you got right), you should get $1/4$.

Then $\mathrm{Cov}(XY) = E[XY] - E[X]E[Y] = 1/4 - 2/3 \cdot 1/3 = 1/36$.

0
On

I swore I answered a similar question some time ago, and after a bit of searching I found it. To be sure, it is not the same density, but the purpose of linking to it is to show that there is a technique that can be applied to make the computation less tedious.

The idea is to let $k, m$ be nonnegative integers and consider $$\begin{align*} \operatorname{E}[X^k Y^m] &= \int_{x=0}^1 \int_{y=0}^x 2 x^k y^m \, dy \, dx \\ &= \int_{x=0}^1 2x^k \left[\frac{y^{m+1}}{m+1} \right]_{y=0}^x \, dx \\ &= \frac{2}{m+1} \int_{x=0}^1 x^k x^{m+1} \, dx \\ &= \frac{2}{m+1} \left[\frac{x^{k+m+2}}{k+m+2}\right]_{x=0}^1 \\ &= \frac{2}{(m+1)(k+m+2)}. \end{align*}$$

Now all that remains is to select appropriate values for $k, m$: For $k = m = 1$, we get $$\operatorname{E}[XY] = \frac{2}{2(4)} = \frac{1}{4};$$ for $k = 1$, $m = 0$, we get $$\operatorname{E}[X] = \frac{2}{1(3)} = \frac{2}{3};$$ and for $k = 0$, $m = 1$, we get $$\operatorname{E}[Y] = \frac{2}{2(3)} = \frac{1}{3}.$$ The covariance is therefore $$\operatorname{Cov}[X,Y] = \frac{1}{4} - \frac{2}{3} \cdot \frac{1}{3} = \frac{1}{36}$$ as claimed. By performing the integration calculation once for the general case, we save the effort of having to integrate a different expression for each expectation.

As the linked post also shows, we can use this to good effect to compute the correlation, since we also have for $(k,m) = (2,0)$ and $(k,m) = (0,2)$ $$\operatorname{E}[X^2] = \frac{1}{2}, \quad \operatorname{E}[Y^2] = \frac{1}{6},$$ thus $$\operatorname{Var}[X] = \frac{1}{18}, \quad \operatorname{Var}[Y] = \frac{1}{18}$$ hence $$\rho_{X,Y} = \frac{1/36}{\sqrt{(1/18)(1/18)}} = \frac{1}{2}.$$

0
On

I would like to post a different solution, with an original approach

Due to the fact that the distribution is uniform in the support

$$0 \leq y \leq x \leq 1$$

(a triangle where one variable is grater than the other one) the problem can be viewed in a different way: Calculate the covariance between $max(X,Y)$ and $min(X,Y)$ where now $X,Y$ are iid uniform rv's on $[0;1]$

so let's set

$U=min(X,Y)$; $Z=max(X,Y)$

and calculate $Cov(U;Z)$

It is well known that

$F_{min}(t)=1-(1-t)^2$

$F_{max}(t)=t^2$

that implies immediately that

$$\mathbb{E}[U]=\int_0^1 2t(1-t)dt=\frac{1}{3}$$

$$\mathbb{E}[Z]=\int_0^1 2t^2dt=\frac{2}{3}$$

Concluding, the requeste covariance is

$$\mathbb{E}(UZ)-\mathbb{E}(U)\mathbb{E}(Z)=\mathbb{E}(XY)-\frac{1}{3}\cdot\frac{2}{3}=$$

$$=\mathbb{E}(X)\mathbb{E}(Y)-\frac{1}{3}\frac{2}{3}=\frac{1}{2}\cdot\frac{1}{2}-\frac{1}{3}\cdot\frac{2}{3}=\frac{1}{36}$$