# Generating random samples from a marginal distribution

I have a joint distribution $p(a,b)$ that I obtained through numerical integration- that is, I don't have a formula for $p(a,b)$ but a bunch of samples drawn from this joint distribution. I would like to obtain samples from the marginal distribution, $p(a)$.
If I had the formula for the joint distribution I could just integrate with respect to $b$, and get $p(a)$. But alas, I don’t have that. What I have is the marginal distribution $p(b)$ (and random samples from that distribution). Can I generate or otherwise obtain samples from the marginal $p(a)$ distribution with what I have?

• See stats.stackexchange.com/questions/134027 (though if you are asking whether knowledge of $p(b)$ may be used to improve upon just taking the samples of $a$, then this is not exactly duplicate). – Juho Kokkala Dec 9 '15 at 18:42

## 1 Answer

This is immediate: given a sample $$(a_1,b_1),\ldots,(a_n,b_n)$$ from $p(a,b)$, the extracted first component sample $$a_1,\ldots,a_n$$ is distributed from $$\int p(a,b)\,\text{d}b=p(a)$$ Hence you have nothing to do!

• Thanks, I think I dont have a handle on what the output of my computer program is giving me! But that is for a different question! – TheBean Dec 9 '15 at 19:36