Conditional vs Marginal

I have a very basic question. Suppose we have a distribution of three variables p(x,y,z) that factors according to a directed graph as follows: p(x,y,z) = p(x)p(y)p(z|x,y). We run MCMC and obtain a trace with samples { (x_i, y_i, z_i) } that we can visualize with pm.traceplot. Let’s say we are interested in the samples {z_i}.

Do samples {z_i} come from the conditional distribution z_i ~ p(z|x, y) or the marginal distribution z_i ~ p(z)?

Each sample $(x_i, y_i, z_i)$ come from the joint probability of $\pi (x, y, z)$, so when you are looking at the traceplot, the smoothed histogram is the marginal distribution of $z$ (after marginalizing $x$ and $y$), but for each i sample $z_i$ it is the conditional given $x_i$ and $y_i$.

1 Like

Thanks! That make sense: if we keep the samples {z_i} and discard {x_i, y_i}, the samples {z_i} ~ p(z) come from the marginal distribution.

It’s important to know since I’m trying to estimate mutual information using sampling and I need to know which distribution the samples are coming from.