# Shortcut for correlation constant

Let $f(x,y) = 1$ if $0 < y <2x$, $0 < x < 1$ and zero otherwise. Find

(a) $f(y |x)$

(b) $E[Y|x]$

(c) $\rho$

Note that $\rho$ is the correlation constant.

In my book the only formula for the correlation constant is $\rho = \dfrac{\sigma_{xy}}{\sigma_x \sigma_y}$ where $\sigma_{xy}$ is the covariance of a pair of random variables X and Y and $\sigma_x = \sqrt{Var(X)}$ and $\sigma_y =\sqrt{Var(Y)}$ are the variance of random variable X and Y respectively.

I've calculated all of them but (c) because there were a lot of calculation and apparently it might be a question on a 50-minute midterm

(a) $f(y|x) = \frac{1}{2x}$

(b) $E[Y|x] = x$

(c) Textbook answer was $1/2$

-
No, $\sigma_x$ and $\sigma_y$ must be the standard deviations of $X$ and $Y$. –  Robert Israel Nov 9 '12 at 3:44
@RobertIsrael, oh yes oops. –  sidht Nov 9 '12 at 4:03

(a) $$f_{Y|X}(y|x) = \frac{f(x,y)}{f_X(x)} = \frac{f(x,y)}{\int_{-\infty}^\infty f(x,t)\ dt}$$ For $0 < x < 1$ we have $f_X(x) = \int_0^{2x} 1\; dt = 2x$, while $f_X(x) = 0$ otherwise. Thus $f_{Y|X}(y|x) = \frac{1}{2x}$ for $0 < y < 2x$ and $0 < x < 1$ (it's wrong to just say $f_{Y|X}(y|x) = 1/(2x)$ without specifying the region of the $xy$ plane for this); $f_{Y|X}(y|x) = 0$ if $0 < x < 1$ and either $y < 0$ or $y > 2x$; $f_{Y|X}(y|x)$ is undefined if $x \le 0$ or $x \ge 1$.

(b) $E[Y|X=x] = \int_{-\infty}^{\infty} y f_{Y|X}(y|x)\ dy$. For $0 < x < 1$ this is $\int_0^{2x} \dfrac{y}{2x}\ dy = x$. Again, for $x \le 0$ or $x \ge 1$ it is undefined.

(c) $E[X] = \int_{-\infty}^\infty x f_X(x)\ dx = \int_0^1 2 x^2\ dx = 2/3$

Similarly, $E[X^2] = \int_0^1 2 x^3\ dx = 1/2$. Thus $\sigma_X^2 = E[X^2] - E[X]^2 = 1/18$.

$E[Y] = E[E[Y|X]] = E[X] = 2/3$

For $0 < x < 1$, $E[Y^2 | X=x] = \int_0^{2x} \dfrac{y^2}{2x}\ dy = \dfrac{4x^2}{3}$ so $E[Y^2] = E[E[Y^2|X]] = E[4 X^2/3] = (4/3) E[X^2] = 2/3$. Thus $\sigma_Y^2 = E[Y^2] - E[Y]^2 = 2/9$.

$E[XY] = E[X E[Y|X]] = E[X^2] = 1/2$ so $\text{Cov}(X,Y) = E[XY] - E[X] E[Y] = 1/18$.

Finally, $\rho = \dfrac{\text{Cov}(X,Y)}{\sigma_X \sigma_Y} = \dfrac{1}{2}$

-
The joint density can be thought of as a right prism of height $1$ with triangular base sitting on the $x$-$y$ plane. The base has vertices are $(0,0)$, $(1,0)$ and $(1,2)$, and thus area $1$. The conditional density of $Y$ given that $X$ has taken on value $x$ is proportional to the cross-section of this prism by the plane at $x$. For $0 < x < 1$, this cross-section is a rectangle with base of length $2x$, and so the conditional density of $Y$ is a uniform density $U(0,2x)$, that is, $$f_{Y\mid X}(y\mid X=x) = \begin{cases}\frac{1}{2x}, & 0 \leq y \leq 2x,\\ & \\ 0, & \text{otherwise.}\end{cases}$$ Since the conditional density is uniform on $(0,2x)$, it follows immediately that $E[Y \mid X=x] = x$.
Turning to the matter of calculating $\rho$, note that by very similar visualization, the conditional density of $X$ given $Y = y$ is a uniform density on $(y/2, 1)$ and thus $E[X \mid Y = y] = 1/2 + y/4$, the midpoint of the base of the uniform density.
Now, $E[Y\mid X = x]$ and $E[X\mid Y = y]$ are the minimum-mean-square-error (MMSE) estimators for $Y$ and $X$ respectively given the value of the other random variable, and since these are linear functions, they are also the MMSE linear estimators for $Y$ and $X$ respectively. Now, the MMSE linear estimators are lines through the mean point $(\mu_X,\mu_Y)$ given by \begin{align*} \frac{y-\mu_Y}{\sigma_Y} &= \rho\frac{x-\mu_X}{\sigma_X}\qquad \equiv \quad y = x\\ \frac{x-\mu_X}{\sigma_X} &= \rho \frac{y-\mu_Y}{\sigma_Y} \qquad \equiv \quad x = \frac{1}{2}+\frac{y}{4} \end{align*} Clearing fractions, we see that $\rho\frac{\sigma_Y}{\sigma_X} = 1$ and $\rho\frac{\sigma_X}{\sigma_Y} = \frac{1}{4}$, giving $\rho^2 = \frac{1}{4}$ and $\rho=\frac{1}{2}$. (The solution $\rho = -\frac{1}{2}$ can be discarded since we know that $\rho$ is positive.)