# Calculate marginal distribution using chain rule

I am trying to calculate the marginal distribution P(X) of the following joint distribution P(X, Y).

y=0 y=1 y=2
x=0 .2 .1 .2
x=1 0 .2 .1
x=2 .1 0 .1

Here is how I am calculating $$P(X=0) = P(X = 0, Y=0) + P(X = 0, Y=1) + P(X = 0, Y=3) = .2 + .1 + .2 = .5$$. Similarly I can find P(X=1) = .3 and P(X=2) = .2, and this looks like the correct approach since P(X = 0) + P(X = 1) + P(X = 2) =1

But if I break the $$P(X,Y)$$ term using the chain rule, I get a different answer. (I've calculated P(Y) by adding the columns.)

\begin{align} P(X=0) &= P(X = 0, Y=0) + P(X = 0, Y=1) + P(X = 0, Y=3) \\ &= P(X =0| Y=0) P(Y=0) + P(X =0| Y=1) P(Y=1) + P(X =0| Y=2) P(Y=2) \\ &= .2 * .3 + .1 * .3 + .2 * .4 \\ &= 0.17 \end{align}

In this approach, P(X=1) = .1 and P(X=2) = .07, and they do not add up to 1.

Why do the results differ when I expand $$P(X,Y)$$ using the chain rule?

Note $$\mathbb P(X=x\mid Y=y) =\frac{\mathbb P[(X=x) \cap(Y=y)]}{\mathbb P(Y=y) }.\tag 1$$
So, $$\mathbb P(X=0\mid Y=0)=\frac{\mathbb P(X=0, Y=0) }{\mathbb P(Y=0) }=\frac{0.2}{0.3}.$$
• Thank you. My mistake was plugging in the value of $P(X \cap Y)$ for $P(X | Y)$. Commented Mar 15, 2023 at 6:53