Functions of random variables are independent => random variables are independent

independenceprobabilityrandom variables

I saw this on a Quora post https://www.quora.com/Are-functions-of-independent-random-variables-also-independent-to-each-other.

I understand that if $X$ and $Y$ are independent, then $f(X)$ and $g(Y)$ are also independent. This doesn't require math and is intuitive for me because if $X$ doesn't affect $Y$, then $f(X)$ also doesn't affect $f(Y)$.

The answer in the Quora post mentions that the reverse is not true, and gives the example that if $X$ and $Y$ are not independent, then $f(X)=X$ and $g(X,Y)=Y-X$ are independent. I don't understand how $f(X)$ and $g(X,Y)$ are independent when both $f()$ and $g()$ involve $X$. Furthermore, if $X$ affects $Y$, then clearly $f(X)$, which is defined to be $X$, affects $g(X,Y)=Y-X$? Can someone explain?

If this example is wrong, could someone provide an example of $f(X)$ and $g(Y)$ being independent when $X$ and $Y$ are not independent?

Best Answer

Perhaps the easiest example is a constant random variable. Every constant is a function of every random variable, and every constant is independent of every random variable (including itself).

So if $X$ and $Y$ are dependent, then e.g. $f(X)=0$ and $g(Y)=0$ are nevertheless independent.

You write “I don't understand how $f(X)$ and $g(X,Y)$ are independent when both $f()$ and $g()$ involve $X$”; so perhaps you’re not so much interested in random variables that are functions of $X$ and $Y$ but in random variables that somehow “involve” $X$ and $Y$.

The example from the Quora post is wrong; $Y-X$ will generally not be independent of $X$. For example, if $Y=-X$, then $Y-X=-2X$, which is not independent of $X$ unless $X$ is constant.

An example with non-constant variables: Let $X$ and $Y$ both be numbers with two binary digits. Their twos digits are the same, determined by a common coin toss, whereas their ones digits are independent, determined by independent coin tosses. Then $X$ and $Y$ are clearly dependent; but their ones digits (which are functions of them) are independent.