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.

  • 3
    $\begingroup$ The answer you have given yourself is correct, yes, this is trivial. $\endgroup$ Jul 10, 2018 at 14:02
  • 1
    $\begingroup$ @kjetilbhalvorsen: stats.meta.stackexchange.com/a/5326/1352 $\endgroup$ Jul 10, 2018 at 14:07
  • $\begingroup$ 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? $\endgroup$ Jul 10, 2018 at 14:16
  • $\begingroup$ @kjetilbhalvorsen: add it as an answer. It's a valid question, even if the answer is short. $\endgroup$ Jul 10, 2018 at 14:21

1 Answer 1


The answer you have given yourself is correct, yes, this is trivial.

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
X_1 <- rnorm(N)
X_2 <- rexp(N)
f  <-  function(x_1,x_2) x_1 * x_2
Y  <-  f(X_1, X_2)
  • 1
    $\begingroup$ @DM-97: If you found this answer helpful, then please consider upvoting and/or accepting it. $\endgroup$ Jul 10, 2018 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.