2

If generating variables $Y | X$, then does one need to simulate independent $X$ for every $Y$ generated or is it enough to simulate $Y$s based on the same $X$?

If e.g. $Y | X \sim N(x,x^2)$ and $X \sim U(-1, 1)$, then can I simulate one $X=x$ and e.g. 100 $Y$s using the same $X$? Or do I have to create a new $X$ for every new $Y$?

mavavilj
  • 4,109
  • 4
    Unclear: it depends on what you want to simulate! – Xi'an Feb 07 '18 at 18:02
  • @Xi'an Then the notation is unclear? But that's what I have written here. – mavavilj Feb 07 '18 at 18:05
  • 2
    It looks like you are trying to simulate from a bivariate random variable $(X,Y)$. If that's the case, doesn't this simpler description answer your question? And if it's not the case, then please edit your post to clarify what you're trying to do. – whuber Feb 07 '18 at 18:27

2 Answers2

2

If you use $X=x$ then you simulate from $Y|X=x$. So if you want to sample from the conditional distribution of $Y$ given random variable $X$, then you need different draws from $X$, because otherwise you'd ignore the variability of $X$. It makes a difference if you sample from $\mathcal{N}(0.5, 0.25)$ or from $\mathcal{N}(X, X^2)$, where $X$ is a random variable. But this is a very general answer, for a general question.

Tim
  • 138,066
1

The conditional distribution of $Y$ conditional on $X=x$ is a distribution indexed by the value $x$: producing an iid sample$$(Y_1,\ldots,Y_n)$$ from this distribution is thus done for this value $x$. For instance, an iid sample from $\mathcal{N}(x,x^2)$.

Simulating from $Y|X$ as in a $\mathcal{N}(X,X^2)$ distribution does not really make sense in that what this means is simulating from a distribution with a random parameter, hence requires a simulation from $X$ prior to each simulation of $Y$ (as W. Huber pointed out), which amounts to simulating from $(X,Y)$ and taking $Y$ as a result. Thus "simulating from $Y|X$" actually means simulating $Y$ from its marginal distribution. Even though this may imply in practice simulating from $X$ first, as in the example of producing an iid sample $(X_1,\ldots,X_N)$ from a $\mathcal{U}(0,1)$ distribution, with value $(x_1,\ldots,x_N)$ then a second sample of $Y_i$'s, with $$Y_i\sim\mathcal{N}(x_i,x_1^2)$. (The $Y_i$'s are marginally iid.)

Xi'an
  • 105,342