## How Copulas Work

*November 25, 2018*

You can simulate a correlated bivariate gaussian distribution easily:

And the marginal distributions are gaussian:

But what if you want a correlated joint distribution where the marginals are whatever distribution you can think of?

You can take your correlated bivariate gaussian sample and feed it through the gaussian CDF function. The resulting distribution is uniform in each dimension but the two uniform distributions are still correlated. To reiterate: you start with a sample that is gaussian in dimension 1, and gaussian in dimension 2, and you end up with a sample that is uniform in dimension 1 and uniform in dimension 2 (but the two uniform dimensions retain the correlation that the original correlated bivariate gaussian sample had.

Here's the uniform joint distribution for the original gaussian sample:

This is an intermediate step. The marginal uniform sample that is jointly correlated is the copula.

And the marginals are uniform:

Then you feed the joint uniform sample through the inverse CDF of whatever distributions you care about. Here I'm using the gamma and beta distributions, but honestly, whatever you want. The resulting joint distribution retains the original correlation from your bivariate gaussian sample:

And the marginals are beta and gamma:

Summary: Correlated joint gaussian -> Intermediate correlated joint uniform -> correlated whatever you want.

The only technical part here is why does the CDF trick work? There's a proof here, but the visual in figure 1 has a good intuitive explanation:

http://www.garp.org/media/691726/quant_classroom_oct2011.pdf