How to numerically choose from a joint, discrete, probability distribution function

I have a two-dimensional β€œheat map” or PDF that I need to recreate using random sampling. I.E. I have a 2D probability density map showing the starting locations. I need to randomly select 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), and then choose random homogeneous numbers to select the CDF. That I'm stuck.

How can I find the common CDF of my PDF file? I tried to make a cumulative sum for both measurements, but this did not give the correct result. My knowledge of statistics does not allow me.

EDIT . Heatmap / PDF is the form [x, y, z], where Z is the intensity or probability at each point x, y.

+6
source share
4 answers

Well, as noted in this answer , for my case it is not necessary that my distribution be double-digit. Since I can normalize all this so that it is a real pdf (the common surface is integrated into 1), I can then rebuild the MxN matrix into a 1xM * N vector. Once I succeed, I can execute the cumulative integral (cumtrapz in MATLAB) and then a sample from this (use a treadmill random number to find the corresponding index value).

+1
source

First you can go over the 2D density map and for each pair (x, y) find z in it by searching from PDF. This will give you the starting point (x, y) with probability z. Thus, each of the starting points has its own probability of PDF. Now you can order the starting points, randomly select a number and match it with some starting point.

For example, let's say you have n starting points: P1 .. Pn. With probability p1 .. pn (normalized or weighted probabilities, so the sum is 100%). Suppose you choose a random value of p, choose P1 if p <p1, choose P2 if p1 <p <p1 + p2, choose P3 if p1 + p2 <p <p1 + p2 + p3, etc. You can consider it as a histogram over the points P1-PN, which is the same as the cumulative distribution function.

+3
source

Here is what I want to do!

I have a joint density function for the independent variables X and Y. And now I want to try the new x, y from this distribution.

I believe that I need to find a joint cumulative distribution, and then somehow a sample from it. This is exactly what you seem to have done.

Could you be more specific when you say that you use "uniform random numbers to find the corresponding index values"?

For reference only: X is the size of orders and orders, and Y is the size of orders in tenders on the stock market.

+1
source

Gibbs Sampling Should Give You What You Want

http://en.wikipedia.org/wiki/Gibbs_sampling

0
source

Source: https://habr.com/ru/post/889155/