Pairwise independence does not imply joint independence (source code)

= Pairwise independence does not imply joint independence
{title2=$Z=X\mathbin\oplus Y$}

Let $X,Y$ be <independent> fair <bits>, and let $Z=X\mathbin\oplus Y$ be their <exclusive or>: $Z=1$ precisely when $X\ne Y$. The four possible triples are $000,011,101,110$, each with <probability> $1/4$. Each coordinate is a fair <bit>. Writing out all eight patterns gives
$$
\begin{array}{c|cccccccc}
(x,y,z)&000&001&010&011&100&101&110&111\\\hline
p_{X,Y,Z}(x,y,z)&1/4&0&0&1/4&0&1/4&1/4&0\\
p_X(x)p_Y(y)p_Z(z)&1/8&1/8&1/8&1/8&1/8&1/8&1/8&1/8
\end{array}
$$
Every pair has all four cells $00,01,10,11$ with <probability> $1/4$:
$$
J_{X,Y}=J_{X,Z}=J_{Y,Z}
=\begin{pmatrix}1/4&1/4\\1/4&1/4\end{pmatrix}.
$$
For $(X,Z)$, the four allowed triples project to $00,01,11,10$; for $(Y,Z)$ they project to $00,11,01,10$. Each projection lists each pair exactly once, proving pairwise independence. But $\mathbb P(X=0,Y=0,Z=0)=1/4$ differs from the product $1/8$, so the three are not <independent random variables>. Indeed, any two determine the third. A single coordinate reveals nothing about another, while two coordinates together reveal it completely.

\Image[/pairwise-versus-joint-independence.png]
{title=The XOR example hides joint dependence from every pairwise probability table}
{description=The bars show all eight triple patterns against the $1/8$ reference for three <independent> fair <bits>. Below, all three pairwise <joint probability mass functions> have four equal cells of $1/4$.}

The <exclusive or> example is the complementary-bit version of the two-toss exercise in https://chance.dartmouth.edu/teaching_aids/books_articles/probability_book/Chapter4.pdf[Grinstead and Snell, Introduction to Probability, section 4.1, exercise 7, printed page 151]. It is a compact reason to check the full product rule whenever a calculation uses three-way or higher <events>.