Covariance and independence? I read from my textbook that $\text{cov}(X,Y)=0$ does not guarantee X and Y are independent. But if they are independent, their covariance must be 0. I could not think of any proper example yet; could someone provide one?
 A: Easy example:  Let $X$ be a random variable that is $-1$ or $+1$ with probability 0.5.  Then let $Y$ be a random variable such that $Y=0$ if $X=-1$, and $Y$ is randomly $-1$ or $+1$ with probability 0.5 if $X=1$.
Clearly $X$ and $Y$ are highly dependent (since knowing $Y$ allows me to perfectly know $X$), but their covariance is zero:  They both have zero mean, and 
$$\eqalign{
\mathbb{E}[XY] &=&(-1) &\cdot &0 &\cdot &P(X=-1) \\
 
&+& 1 &\cdot &1 &\cdot &P(X=1,Y=1) \\

&+& 1 &\cdot &(-1)&\cdot &P(X=1,Y=-1) \\

&=&0.
}$$
Or more generally, take any distribution $P(X)$ and any $P(Y|X)$ such that $P(Y=a|X) = P(Y=-a|X)$ for all $X$ (i.e., a joint distribution that is symmetric around the $x$ axis), and you will always have zero covariance.  But you will have non-independence whenever $P(Y|X) \neq P(Y)$; i.e., the conditionals are not all equal to the marginal. Or ditto for symmetry around the $y$ axis. 
A: Here is the example I always give to the students. Take a random variable $X$ with $E[X]=0$  and $E[X^3]=0$, e.g. normal random variable with zero mean.  Take $Y=X^2$. It is clear that $X$ and $Y$ are related, but
$$Cov(X,Y)=E[XY]-E[X]\cdot E[Y]=E[X^3]=0.$$
A: The image below (source Wikipedia) has a number of examples on the third row, in particular the first and the fourth example have a strong dependent relationship, but 0 correlation (and 0 covariance).

A: Some other examples, consider datapoints that form a circle or ellipse, the covariance is 0, but knowing x you narrow y to 2 values.  Or data in a square or rectangle.  Also data that forms an X or a V or a ^ or < or > will all give covariance 0, but are not independent.  If y = sin(x) (or cos) and x covers an integer multiple of periods then cov will equal 0, but knowing x you know y or at least |y| in the ellipse, x, <, and > cases.
A: Inspired by mpiktas's answer.
Consider $X$ to be a uniformly distributed random variable, i.e. $X \sim U(-1,1) $. Here, $$E[X] = (b+a)/2 = 0.$$ $$E[X^2] = \int_{-1}^{1} x^2  dx = 2/3$$ $$E[X^3] = \int_{-1}^{1} x^3 dx = 0$$
Since $Cov(X, Y) = E[XY] - E[X] \cdot E[Y]$, $$ Cov(X^2, X) = E[X^3] - E[X] \cdot E[X^2] \\ = 0 - 0 \cdot 2/3= 0 $$ Clearly $X$ and $X^2$ are not independent. But their covariance is computed to be zero. Since a counter example has been found, the proposition is false in general.
