0

I have seen this approach link in different places. Hence, I suppose that the following method is correct.

Let $f_{X,Y,Z}(x,y,z)=f_{X|Y,Z}(x|y,z)f_Y(y)f_Z(z)$ and I can easily sample from these 3 densities.

To sample from the marginal $f_X(x)$ we can do:

  1. For $j=1,\cdots,N$
  2. Sample $(y,z)^j=y^j \sim f_Y, z^j \sim f_Z$
  3. Sample $(x,y,z)^j = x^j \sim f_{X|Y,Z}(\cdot|y^j,z^j)$
  4. Keep only $\{x\}$

Is it correct?

My question is, can this method be used to sample from $f_{X|Y}(x|y)$ for example?

user1571823
  • 113
  • 4
  • 1
    That is correct! – jbowman Aug 12 '21 at 18:54
  • what about f(x|y)? because i guess keeping {x,y} is equivalent to f(x,y). Right? – user1571823 Aug 12 '21 at 19:08
  • 2
    By definition, the marginal density is what you obtain when you ignore the other variables. Thus, if your algorithm *just happens* to generate one or more of those other variables, you are under no obligation to pay attention to them. – whuber Aug 12 '21 at 19:20

0 Answers0