1st Yr Probability: Independence of flipping a fair coin twice Background
This is the most simple and basic example of independence.
But unsurprisingly I am having issues with it due to brain shortcomings.


*

*You flip a fair coin twice

*$X =$ # of heads in the first flip (Bernoulli)

*$Z =$ # of heads in both flips (Binomial)
My problem


*

*It makes sense to me that $X$ and $Z$ are dependent. If you know $Z=0$ then $X=0$

*Let's create a new random variable $Y = Z - X$

*Now if you started off by defining $Y = $ # of heads in the second flip, then it's super clear to me that  $X$ and $Y$ are independent. Knowing the outcome of the first flip doesn't say anything about the second flip

*But if you define $Y$ as $Z - X$ then it is less clear to me that $X$ and $Y$ are independent, because we established that $Z$ and $X$ are dependent and $Y$ has $Z$ in it

*It's weird to me that $X$ and $Z$ are dependent but $X$ and $Z-X$ are independent
Can you explain (pedantically so I understand) where I'm going off the rails?
Thanks for your help and patience.

As long as the coins are unbiased:
If you know $Z-X=0$ then you may have either $\{X=0, Z=0\}$ xor $\{X=1, Z=1\}$ with equal probability.
If you know $Z-X=1$ then you may have either $\{X=0, Z=1\}$ xor $\{X=1, Z=2\}$ with equal probability.
So knowing what $Z-X$ equals does not provide any information about what $X$ alone may equal.   Thus $X, Z-X$ are pairwise independent.

However, knowing any one of the three does provide information on what values the other may jointly be.   $X, Z, Z-X$ are jointly dependent.
