Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are some techniques for sampling two correlated random variables:

  • if their probability distributions are parameterized (e.g., log-normal)

  • if they have non-parametric distributions.

The data are two time series for which we can compute non-zero correlation coefficients. We wish to simulate these data in the future, assuming the historical correlation and time series CDF is constant.

For case (2), the 1-D analogue would be to construct the CDF and sample from it. So I guess, I could construct a 2-D CDF and do the same thing. However, I wonder if there is a way to come close by using the individual 1-D CDFs and somehow linking the picks.


share|improve this question
Linking 1-D CDFs makes me think of copulas. Not sure if they'd be any use to you. – onestop Feb 22 '11 at 20:59
up vote 14 down vote accepted

I think what you're looking for is a copula. You've got two marginal distributions (specified by either parametric or empirical cdfs) and now you want to specify the dependence between the two. For the bivariate case there are all kinds of choices, but the basic recipe is the same. I'll use a Gaussian copula for ease of interpretation.

To draw from the Gaussian copula with correlation matrix $C$

1) Draw $(Z=(Z_1, Z_2)\sim N(0, C)$

2) Set $U_i = \Phi(Z_i)$ for $i=1, 2$ (with $\Phi$ the standard normal cdf). Now $U_1, U_2\sim U[0,1]$, but they're dependent.

3) Set $Y_i = F_i^{-1}(U_i)$ where $F_i^{-1}$ is the (pseudo) inverse of the marginal cdf for variable $i$. This implies that $Y_i$ follow the desired distribution (this step is just inverse transform sampling).

Voila! Try it for some simple cases, and look at marginal histograms and scatterpolots, it's fun.

No guarantee that this is appropriate for your particular application though (in particular, you might need to replace the Gaussian copula with a t copula) but this should get you started. A good reference on copula modeling is Nelsen (1999), An Introduction to Copulas, but there are some pretty good introductions online too.

share|improve this answer
+1 Nelsen is quite readable. I bought a copy a few years ago even after going through a lot of the online materials. – whuber Feb 22 '11 at 21:36
I found a great tutorial paper and accompanying spreadsheet: and – Pete Mar 7 '11 at 15:33
@Pete, the paper is indeed nice. The spreadsheet link, on the other hand, is dead – bgbg Sep 17 '12 at 12:59
It seems the recent versions of Mathematica and Matlab already has built-in-functions handling such issue? – LCFactorization May 29 at 11:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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