# Is this true: $\mathrm{Cov}(X,Y) = \sqrt{\mathrm{Var(X)}}\sqrt{\mathrm{Var}(Y)}$?

I just want to confirm whether this is correct or not:

The covariance of $X$ and $Y$ is equal to the standard deviation of $X$ times the standard deviation of $Y$.

or, in mathematical notation,

$$\mathrm{Cov}(X,Y) = \sqrt{\mathrm{Var(X)}}\sqrt{\mathrm{Var}(Y)}$$

-

i see. Thanks for help – user10128 Apr 27 '11 at 12:07
@cardinal: ... and perhaps also posted the answer as an answer instead of as a comment? As it is now, the question is answered even though it appears as unanswered on the front page. – Hans Lundmark Apr 27 '11 at 12:24
@Hans, fair enough. I've copied my comment into an answer and deleted the comments. – cardinal Apr 27 '11 at 12:30
@Hans, also, if you don't mind, please review my edit of the question and approve it, if appropriate. I think that will also make my answer match up better with the question. Cheers. – cardinal Apr 27 '11 at 12:32
@cardinal: Looks fine to me. :) – Hans Lundmark Apr 27 '11 at 12:49

## 2 Answers

This is false in general. In fact, it is true if and only if $X=aY+b$ (almost surely) for some fixed constants $a \geq 0$ and $b \in \mathbb{R}$. That is $X$ and $Y$ must be positively linearly related for this to hold. Wikipedia also has a decent page on this.

For a counterexample to your statement, consider any two independent random variables $X$ and $Y$ each with strictly positive variance. Then, $\mathrm{Cov}(X,Y) = 0 \>,$ but, $\sqrt{\mathrm{Var}(X)} \sqrt{\mathrm{Var}(Y)} > 0 \>.$

A quick proof (and a slick one, I think; it's not my own) of the if and only if assertion uses the Cauchy–Schwarz inequality and goes as follows. Let $U$ and $V$ be random variables such that $\newcommand{\e}{\mathbb{E}}\e U^2 < \infty$ and $\e V^2 < \infty$. Then, $|\e UV|^2 < \e U^2 \e V^2$ if and only if $\e (t U - V)^2 > 0$ for all $t$. But, if $\e(t_0 U - V)^2 = 0$ for some $t_0$, then $t_0 U = V$ almost surely. Now, set $U = X - \e X$ and $V = Y - \e Y$ to get the desired conclusion.

-

1
+1 though with a pedantic point: suppose $Z$ is a uniform random variable from $[0,1)$, $Y=1$ if $Z$ is rational and $Y=0$ if $Z$ is irrational, and $X=1-Y$. Then $\mathrm{Cov}(X,Y) = \sqrt{\mathrm{Var(X)}}\sqrt{\mathrm{Var}(Y)}$ even though $a \lt 0$. – Henry May 14 '12 at 22:35
@Henry: (+1) Thank you; it's not pedantic at all. I'm not sure how you came across such an old answer, but I appreciate very much your comment. I'll try to think of a way to clean up the statement. This should only be possible if one of the random variables is almost surely constant. – cardinal May 15 '12 at 2:46

While cardinal has answered the question, I wanted to add a little something extra.

The Cauchy-Schwarz inequality shows that $\left|\operatorname{Cov}(X,Y)\right|\leq \sqrt{\operatorname{Var}(X)\operatorname{Var}(Y)}$, with equality if and only if $X$ and $Y$ are linearly dependent. In general, you can take the ratio $\rho=\frac{\operatorname{Cov}(X,Y)}{ \sqrt{\operatorname{Var}(X)\operatorname{Var}(Y)}}$ which will be between $-1$ and $1$. This gives the correlation between $X$ and $Y$. It is $1$ when the variables are perfectly correlated (one goes up exactly when the other does), $-1$ when they are perfectly anti-correlated (one goes up exactly when the other goes down), $0$ when they are independent (knowing that one goes up tells you nothing about the behavior of the other), and in general gives a measure of the behavior when things are somewhere in between.

One of the first places where this comes up is least squares approximation. . While you can always do a least squares approximation to get a line of best fit for your data points, the correlation coefficient tells you whether your line of best fit is actually a good fit. It will be near $0$ for data that is essentially random, and small in magnitude for data which is non-linear.

-

(+1) Your last statement depends strongly on the type of nonlinearity present. There are many cases where even in the presence of considerable nonlinearity, the correlation coefficient will not be small in magnitude. – cardinal Apr 27 '11 at 13:52
@cardinal Yes.  I guess that by "non-linear" I actually mean "not well approximated by anything linear" or "very non-linear".  On the other hand, this could be used as a definition of what it means for noisy data to be linear/non-linear. – Aaron Apr 27 '11 at 14:27
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 47, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9481037855148315, "perplexity_flag": "head"}