Generating random data from a discrete multimodal distribution I have a $n \times n$ distribution grid that represents the likelihood of finding a person within an area (see below). From this I would like to be able to create $x$ samples that fit this distribution.
Ideally $50\lt x \lt200$, and $10 \lt n \lt 50$. This is to simulate some search and rescue scenarios for a few path planning algorithms based on this distribution grid.

 A: If I translate in mathematical terms what I believe you said, we have that if we designate by by $(a_{i,j})_{1\le i,j\le n}$ the cases of your grid and $X$ a person, then you have the data of the probability that person $X$ pop up in case $a_{i,j}$. i.e., you have access to the $n^2$ numbers $(p_{i,j})_{1\le i,j\le n}$ such that
$$\mathbb{P}(X \text{ is in the case } a_{i,j})=p_{i,j}.$$
and you want to be able to sample from this distribution ($\mathbb{P}$ stands for "the probability that").
This is a multinomial distribution (not multimodal, multimodal means another thing, see wikipedia). Just draw according to a multinomial distribution with parameters $(p_{1,1},p_{1,2}, \dots,p_{1,n},p_{2,n},\dots,p_{n,n})$, the fact that this is in 2D does not really matter, you can use the multinomial right away saying that if you draw a $1$ from the multinomial, your person is in case $a_{1,1}$, if you draw a $n$ he is in case $a_{1,n}$, if you draw a $(n+1)$ he is in case $a_{1, 2}$, if you draw $(3\times n+6)$, he is in case $a_{6,3}$... (you can enumerate the cases of your grid as you wish, I only give an example).
Drawing from a multinomial distribution is relatively easy using python or matlab.
A: Using what @TMat said, I got this code to work using numpy
img = Image.open("path/to/img")
img = np.array(img)[:,:,0]
prob = (np.array(img)/np.sum(img)).flatten()

x,y = np.meshgrid(np.arange(0,img.shape[0]),np.arange(0,img.shape[1]))
x,y = x.flatten(),y.flatten()
xy  = np.vstack((x,y)).T

xy_indices = np.arange(len(xy))

choices = np.random.choice(xy_indices, 200, p=prob)

points = xy[choices]


