# Covariance of $f(X)$ and $Y$

Assume that $X$ and $Y$ have a positive covariance, and $f$ is a decreasing function. Can I say that $f(X)$ and $Y$ have a negative covariance?

Try the decreasing function $f(X) = 2^{2-X}$ and find the covariances for the data

X  Y  f(X)
1  10  4
2   0  2
3  11  1


Both covariances should be positive

@Henry - Very neat! In fact the OP conjecture is not even close to true:

 Y    X    f(X)
1   a>0   c<0
-2    0     0
1   b<0   d>0


$Cov(X,Y) = E[XY] - E[X]E[Y] = E[XY]$ in this example since by construction $E[Y] = 0$. So $Cov(X,Y) = \frac{a+b}{3}$ and $Cov(f(X),Y) = \frac{c+d}{3}$ and each of them can be any real number.

E.g., you can have $Cov(X,Y)>0$ and then after applying the decreasing $f$ to $X$, you end up with $Cov(f(X),Y)$ even larger (more positive), such as when $(a,b,c,d)=(10,-1,-1,100)$.

If you visualize the 3 points on a plane, and further visualize covariance as a sort of "best fitting ellipse", it is pretty clear what is going on. Swapping the two $Y=1$ points around wouldn't have done much except that the $(0,-2)$ point then "tilts" the "best-fitting ellipse", and by choosing $(a,b,c,d)=(10,-1,-1,100)$ the tilts both before and after are positive slopes. And since covariance is also a measure of the "size" of this ellipse, there is no limit to the values before and after.

This does leave open a question of whether the CORRELATION (not covariance) can change arbitrarily from any value in $(0,1]$ to any value in $(0,1]$, since that is not "size" dependent...