I would like to random sample points within an n-sided polygon. One idea I've thought of is to discretize the area of the n-sided polygon with triangles.
I can assign each triangle a unique number in the range $[1, M]$ where $M$ is the number of triangles. Assuming the triangle areas are equal, I can use a uniform distribution $\sim U(1, M)$ to random sample a triangle and use its centroid as the random sampled point within the polygon.
The problems with this approach are:
(1) It's a discrete approximation since I'm mapping a triangular region to a single value, i.e., the centroid. Is there a straightforward continuous approach?
(2) The assumption that the rectangles have the same area. In practice, if I have some irregular shape, I think it would be quite difficult to get all the triangle areas to be the same. Is there some sort of weighted uniform distribution you could use?
One thought that I had was to say use $\sim U(0,1)$ and for each $A_i$ (area of i-th triangle) we assign a specific range within [0, 1] where the range spans the normalized area of $A_i$. e.g., say you had 2 triangles that discretized some n-sided polygon. Say $A_1 = 50, A_2 = 100$. Then $50/(50+100) = 1/3$ and $100/(150) = 2/3$. So we could take anything within $[0, 1/3]$ and $[1/3, 1]$ from $\sim U(0,1)$ as corresponding to the first and second triangles, respectively.
What are some other approaches?
One approach that I've used with spheres is rejection sampling, but spherical surfaces are quite easily described by an equation, so rejection sampling becomes simply. For an n-sided polygon, this would seem rather difficult as there would be an equation corresponding to each side, so checking whether to accept or reject a random sample would be tedious.
