# Does the specific bias random coins determines whether functions of these are independent or not?

Consider 3 independent r.v.s $X_1$, $X_2$, $X_3$ that represent the outcomes of three (independent) fair coin tosses. Let 1 denote heads and 0 denote tails.

Let two new random variable be defined as follow:

$$X_4 = \mathbb{1}\{X_1 = X_2\}$$

and

$$X_5 = \mathbb{1}\{X_2 = X_3\}$$

why is it that, if the coins were NOT biased, then $X_5 \perp X_4$ does not necessarily hold? Is $\frac{1}{2}$ the only set of probability values for $X_1$, $X_2$, $X_3$ that make $X_5$ and $X_4$ independent? Can this be proven rigorously and precisely? What is the intuition for the solution? Is the answer to this suppose to be very obvious, because it was told to me as if it was really obvious but I am having a hard time really convincing myself of it...

Is it really "obvious" that $X_5 \perp X_4$ holds iff $Pr[X_i=1] = \frac{1}{2}$

What I had so far was that, if we want $X_5 \perp X_4$ to be satisfied, then we must have:

$$Pr[X_5 = x_5 , X_4 = x_4] = Pr[X_5 = x_5]Pr[X_4 = x_4]$$

So lets see how we can make $Pr[X_5 = x_5 , X_4 = x_4]$ be the product that we want.

We know that:

$$Pr[X_4] = \sum_{(x_1,x_2) s.t. x_1 = x_2} Pr[X_2=x_2,X_1=x_1]$$

Since $X_i$'s are mutually independent then we have:

$$Pr[X_4] = \sum_{(x_1,x_2) s.t. x_1 = x_2} Pr[X_2=x_2]Pr[X_1=x_1]$$

but then I was not sure how to move on. Not sure if I am on the right track...

If the coins are identical with head probability $p$, then to get the independence you want would require:
$(p^2 +(1-p)^2)^2 = p^3 + (1-p)^3$ (LHS is $P(X4=1)*P(X5=1)$ and RHS is $P(X4=X5=1)$).
This polynomial is a quartic in $p$ whose roots are $0, 1/2$ (double root), and $1$.
So the (identical) coins that work are the fair coin and trivial coins with $p = 0, p = 1$.