[Math] An example of two random variables that are mean independent but not independent

conditional-expectationexpectationindependenceprobabilityprobability theory

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.

Best Answer

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}$.