# if 3 random variables are independent, then any pair is independent given the remaining random variable

How do I prove the following: $$X,Y,Z$$ are independent, then any pair is independent given the remaining random variable.

I know that $$E(X|Z)=E(X)$$ and $$E(Y|Z)=E(Y)$$

so $$E(XY)=E(X)E(Y)=E(X|Z)E(Y|Z)$$

does it imply that $$E(X|Z)E(Y|Z)=E(XY|Z)$$

On the other hand, if $$X,Y,Z$$ are pairwise independent, how do I disprove that any pair is independent given the remaining random variable?

$$X,Y,Z$$ are independent, hence, $$P(X,Y,Z) = P(X) P(Y) P(Z)$$. Then,

$$P(X,Y \mid Z) = \frac{P(X,Y,Z)}{P(Z)} = \frac{P(X) P(Y) P(Z)}{P(Z)}$$ This proves that $$X,Y \mid Z$$ are independent, since $$P(X,Y \mid Z) = P(X)P(Y)$$. The same proof goes to the other cases.

For the case you want to disprove, just use the following counter-example: You can easily check that they are pairwise independent. But their collection is not independent. Just doing some calculations:

$$P(X,Y \mid Z) = \frac{P(Z \mid Y,X)P(X,Y)}{P(Z)}= \frac{P(Z \mid Y,X)P(X)P(Y)}{P(Z)}$$

But $$P(Z=1 \mid X=1, Y=1)=0 \neq P(Z=1)=0.5$$. So we conclude that $$P(X,Y \mid Z) \neq P(X)P(Y)$$ which is what we wanted to disprove.