2
$\begingroup$

Please consider the following probability density function of two variables. \begin{eqnarray*} f(x_1,x_2) &=& \begin{cases} 2(x_1+x_2) & \text{for} \,\, 0 \le x_1 \le x_2 \le 1\\ 0 &\text{ otherwise } \\ \end{cases} \end{eqnarray*} I would like to generate two random values $X_1$ and $X_2$ such that there distribution is consistent with the above probability density function.

If the above probability density function was of just one variable, then I would solve the above problem with the following steps.
1) I would find the distribution function $F$ by integrating.
2) I would generate a random number $a$ on the interval $[0,1]$ using the uniform distribution.
3) I would find a number $X$, such that $F(X) = a$. Then $X$ would be the random number I seek.
I am wondering whether a similar method would work for a function of two variables.

$\endgroup$

1 Answer 1

1
$\begingroup$

This is the problem of sampling from a multivariate distribution.

Simple method

In your case, there is a fairly simple method that will probably suffice. First, randomly pick a value for $X_1$ according to the marginal distribution on $X_1$. In other words, we define

$$g(x_1) = \int_{x_2=x_1}^{x_2=1} f(x_1,x_2) \; dx_2,$$

the probability density function for $x_1$, and sample $X_1$ according to $g$. Since this is a univariate distribution, you already know how to do that (using the methods you described). Here we have $g(x_1) = 1 + 2x_1 - 3 x_1^2$.

Second, randomly pick a value for $X_2$ according to the conditional distribution on $X_2$ given the value of $X_1$ picked earlier. This has probability density

$$h_{x_1}(x_2) = f(x_1,x_2)/g(x_1),$$

which is also a univariate distribution, so you already know how to sample from $X_2$ (once $X_1$ is fixed).

More general method

Alternatively, you can apply any of the general methods for sampling from a multivariate distribution. They are probably shooting a fly with a cannon -- they're probably much more complex than what you need. But if you want a relatively simple one, you could take a look at slice sampling.

$\endgroup$

Your Answer

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

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