I have a 2D “heat map” or PDF that I need to recreate by random sampling. I.E. I have a 2D probability density map showing starting locations. I need to randomly choose starting locations with the same probability as the original PDF.
To do this, I think I need to first find the joint CDF (cumulative density function), then choose random uniform numbers to sample the CDF. That’s where I get stuck.
How do I numerically find the joint CDF of my PDF? I tried doing a cumulative sum along both dimensions, but that didn’t yield the correct result. My knowledge of statistics is failing me.
EDIT The heatmap/PDF is the form of [x,y,z], where Z is the intensity or probability at each x,y point.
Well, as observed in this answer, for my case it doesn’t necessarily matter that my distribution is bivariate. Since I can normalize the whole thing so that it’s a true pdf (total surface integrates to 1), I can then rearrange the MxN matrix into a 1xM*N vector. Once I have that, I can do a cumulative integral (cumtrapz in MATLAB), and then sample from that (use a uniform random number to find the corresponding index value).