# How can I get a sample of a product of two independent random variables?

I have three random variables: $X_1$, $X_2$ and $Y$ such that $X_1$ and $X_2$ are independent and $Y = X_1 \times X_2$. I think that either this question is trivial or I'm making a rookie error, but I'm not sure which.

I have samples of $X_1$ and $X_2$ as two vectors. If I multiply these vectors point-wise, does this give me a sample of $Y$? If not, how can I obtain such a sample?

I'm also interested in more general cases where $Y = f(X_1,X_2,\dots, X_n)$, for some function $f$ where samples of the $X_i$ are given.

• The answer you have given yourself is correct, yes, this is trivial. Jul 10, 2018 at 14:02
• @kjetilbhalvorsen: stats.meta.stackexchange.com/a/5326/1352 Jul 10, 2018 at 14:07
• Do you think it should be closed as too marginal? I have used all my close votes today ... but I can add as an answer? Jul 10, 2018 at 14:16
• @kjetilbhalvorsen: add it as an answer. It's a valid question, even if the answer is short. Jul 10, 2018 at 14:21

For the sake of completeness: Let $f$ be a function of two arguments, $X_1, X_2$ be two independent random variables. Define the random variable $Y$ by $Y=f(X_1, X_2)$. Then to simulate a sample of independent realization of $Y$, simulate first independent realizations of $X_1$, then independent from that, a sample of independent realizations from $X_2$ and then use $f$ to compute $Y$. A simple example in R:
N <- 1000