Simulate samples from a joint cumulative distribution function?

distribution, matlab, probability, random, sampling

Solution

If you know how to sample a distribution in 1D then you can extend it to 2D. Create the marginal distribution for X. Take a sample from that, say X1. Then in your 2D distribution fix one variate X=X1 and sample for Y, i.e., sample Y from 1D distribution fXY(X1, Y).

Problem

I have a joint density function for two independent variables X and Y. And I now want to sample new x,y from this distribution. What I believe I have to do is to find the joint cumulative distribution and then somehow sample from it. I kinda know how to do this in 1D, but I find it really hard to understand how to do it in 2D. I also used the matlab function `cumtrapz` to find the cumulative distribution function for the above pdf. Just to be clear, what i want to do is to sample random values x,y from this empirical distribution. Can someone please point me in the right direction here?! EDIT: I have data values and I use [pdf bins] = hist3([N Y]) I then normalize the pdf and do cumulativeDistribution = cumtrapz(pdfNormalize) And yes (to the comment below) X,Y are suppose to be independent.

Original source