# An example of two random variables that are mean independent but not independent

In probability theory class I was asked the following question:

Let X,Y be two random variables (could be discrete or continuous) such that they are mean independent, that is for all $y \in \mathbb{R}$ we have the equality: $E[X|Y=y] = E[X]$ and we are asked to prove or give a counterexample that X and Y are independent random variables.

I figured since I tried to prove it but could not succeed so I am inclined to think that it is false but I cannot find a counterexample. Could someone then please provide an example of random variables that are dependent but mean independent? Thank you all.

• Say $X$ is uniform on $[-1,1]$, so $E[X]=0$. Let $Y=X^2$. – lulu Mar 25 '16 at 15:23
• These are dependent, not independent. Indeed, $X$ determines $Y$. If you fix a value for $Y$, say $Y=y\in [0,1]$ then $X$ is either $\pm \sqrt y$ with equal probability, hence the expected value of $X$ , conditioned on the value of $Y$, is $0$. – lulu Mar 25 '16 at 15:29
• Verrrry related... math.stackexchange.com/q/1713013 – Did Mar 25 '16 at 15:32
• Alternatively, pick $Y$ first in $(0,1)$ uniformly, then pick $X$ uniformly in $(-y,y)$. Then $E(X)=0$ and $E(X\mid Y=y)=0$. These two are not independent. – Thomas Andrews Mar 25 '16 at 15:34
• @Did thanks I should have noticed that – Don John Prep Mar 25 '16 at 15:35

Pick $Y$ uniformly from $[0,1]$. Then pick $X$ uniformly from $[-y,y]$.
Then $E(X)=0$ and $E(X\mid Y=y)=0$, but $P\left(X<\frac{-1}{2}\mid Y=\frac{1}{4}\right)=0$, and $P\left(X<\frac{-1}{2}\right)=\frac{1}{8}$, so they are not independent.
In general, pick $Y$ First, and then let $Y$ determine a distribution for $X$ with the same mean.
For example, the case given by comments above, of picking $X$ uniformly from $(-1,1)$ and $Y=X^2$ can be seen this way - first pick $Y$ from $(0,1)$ with $P(Y<y)=\sqrt{y}$ and then pick $X$ uniformly from $-\sqrt{Y}$ or $\sqrt{Y}$.