Generating points in rectangle

1.1k Views Asked by At

I am trying to generate $N$ points randomly and uniformly distributed in an $m \times n$ rectangle. How can this be done? I have tried to split the initial rectangle into as many rectangles i could, but this didn't work.

1

There are 1 best solutions below

2
On

For each point, independently generate two numbers: $l_i\sim U(0,m)$ and $h_i\sim U(0,n)$. The resulting point $(l_i,h_i)$ is a point in the rectangle and the joint distribution is uniform over the entire rectangle.