TITLE: Correlation Coefficient as Cosine
QUESTION [9 upvotes]: I've read that the correlation coefficient between two random variables may be viewed as the cosine as the angle between them, but I can't find any solid explanation.
To be concrete, let $X$ and $Y$ be random variables on $(\Omega, \mathcal{F}, P)$ with correlation coefficient $\rho$.  Assume $X,Y \in L^2(\Omega,\mathcal{F},P)$.  The quantity $\rho$ is defined as
$$
\rho := \frac{Cov(X,Y)}{\sqrt{Var(X)Var(y)}}.
$$
Letting $\mu_X := E(X)$ and $\mu_Y := E(Y)$, note
$$
Cov(X,Y) = E((X - \mu_X)(Y - \mu_Y)) = \left< X - \mu_X, Y - \mu_Y\right>_{L^2}
$$
and
$$
Var(X) = E((X - \mu_X)^2) = ||X - \mu_X||_{L^2}^2,
$$
where $L^2 := L^2(\Omega, \mathcal{F}, P)$.  Thus
$$
\rho = \frac{\left< X - \mu_X, Y - \mu_Y\right>_{L^2}}{||X - \mu_X||_{L^2} ||Y - \mu_Y||_{L^2}}. \qquad (1)
$$
Compare this with the Euclidean space inner product result that for two vectors $x,y \in \mathbb{R}^n$,
$$
\cos(\theta) = \frac{x^Ty}{||x||\, ||y||},
$$
where $\theta$ is the angle between $x$ and $y$.
The recurring claim I read is that I can think of $\rho$ as the cosine of the "angle" between the two random variables, but it seems it only makes sense in terms of $L^2$ inner products.  But in that case, the only notion of "angle" between to elements $X,Y \in L^2$ I can think of is
$$
\cos(\theta) = \frac{\left< X,Y \right>_{L^2}}{||X||_{L^2} ||Y||_{L^2}}. \qquad (2)
$$
So, two questions:

Is Eqn. (2) a valid notion of angle in $L^2$?
Are Eqns (1) and (2) somehow equlivalent?

If both of these are true, I can justify viewing $\rho = \cos(\theta)$.

REPLY [2 votes]: $X-\mu_X$ is the projection of $X$ onto the plane $E=0$ in $L^2$. So $\rho$ measures the angle between the two projected vectors $X-\mu_X$, $Y-\mu_Y$. This has the effect that replacing $X$ by an "affine replica" $\alpha X+\beta$ resulting from a change of scales (think of $X$ being a temperature) does not change $\rho$.