Suppose that I have a number of variables. Each is known to be Gaussian or uniformly random with known parameters and occur with a known probability. I also have a table of correlations (or covariances if that's easier) for each one. It would be great if these parameters could come from any kind of distribution, but if not, uniform and Gaussian are fine for my interests.

So, a typical problem case would be A is Gaussian with mean a1 and variance a2; B is uniform with maximum b1 and minimum b2. C is Gaussian with mean c1 and variance c2. Then I have a table of correlations A with B, A with C and B with C.

How would I write an algorithm to generate a sample of random vectors (A,B,C) which satisfy the above properties. Again, it would be really great if the variables could come from any kind of distribution, but I would settle for at least Gaussian only, uniform only or a mixture of Gaussian and uniform variables.

It would be nice to have an approach that would scale up easily.

I would like to implement this myself, rather than use some predefined package. So, I'm interested in algorithmic details.

  • $\begingroup$ Do you mean that $(A,B,C)$ occurs then you pick $A$ with probability $p_1$, $B$ with probability $p_2$, and $C$ with probability $p_3$? $\endgroup$
    – Xi'an
    Nov 17 '12 at 19:52
  • $\begingroup$ I removed the comments about probability. I realize now that it made no sense. $\endgroup$
    – Henry B.
    Nov 17 '12 at 21:56
  • $\begingroup$ Sorry, in my opinion, it makes less sense now... $\endgroup$
    – Xi'an
    Nov 17 '12 at 22:13
  • $\begingroup$ @Xi'an. Imagine a population of people with height, weight, eye color. Now, lets say height is Gaussian, weight is Gaussian and eye color is Binomial. There are measured correlations between all these variables. I am wondering if there is a procedure for generating a person from this population randomly. $\endgroup$
    – Henry B.
    Nov 17 '12 at 22:44
  • $\begingroup$ If the corresponding multivariate distribution is fully defined, then the answer is yes. If instead you only know the marginals and the correlation between the components, the answer is no, because there is not a single distribution with those characteristics. $\endgroup$
    – Xi'an
    Nov 18 '12 at 8:41

If I understand correctly the setup, a pseudo-algorithm to generate from this distribution would be

  1. generate $(A,B,C,...)$ from their joint distribution
  2. take as your random variable a component of this vector selected with probability $p_1,p_2,\ldots$

For instance, if the joint of $(A,B,C)$ is normal $\cal{N}(\mu,\Sigma)$,

  1. generate $(A,B,C)\sim\cal{N}(\mu,\Sigma)$
  2. take $X=\begin{cases}A &\text{with probability }p_1\\B &\text{with probability }p_2\\C &\text{with probability }p_3\end{cases}$

with a corresponding R code for n simulations (assuming mu, Sigma and prob properly defined):


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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