Sampling from marginal distribution using conditional distribution?

I want to sample from a univariate density fX but I only know the relationship:


I want to avoid the use of MCMC (directly on the integral representation) and, since fX|Y(x|y) and fY(y) are easy to sample from, I was thinking of using the following sampler:

  1. For j=1,,N.
  2. Sample yjfY.
  3. Sample xjfX|Y(|yj).

Then, I will end up with the pairs (x1,y1),...,(xN,yN), and take only the marginal samples (x1,,xN). Is this correct?


Yes, this is correct. Basically, you have


and as you said, you can sample from the joint density. Picking up just the xs from the samples leads you to a sample from the marginal distribution.

This is because the act of ignoring the y is akin to integrating over it. Lets understand this with an example.

Suppose X = Height of mothers and Y = Height of daughter. The goal is to get a sample from (X,Y) to understand the relation between the heights of daughters and their mothers. (I am making the assumption that there is only one daughter in the family, and restricting the population to all daughters over age 18 to ensure full growth).

You go out and get a representative sample

Thus for each mother, you have the height of their daughter. There should be a clear relationship between X and Y. Now suppose from your dataset, you ignore all the data on the daughters (drop the Y), then what do you have? You have exactly heights of randomly chosen mothers which will be N draws from the marginal of X.

Source : Link , Question Author : Rod , Answer Author : Greenparker

Leave a Comment