Article 6ZZMT Random samples from a polygon

Random samples from a polygon

by
John
from John D. Cook on (#6ZZMT)

Ted Dunning left a comment on my post on random sampling from a triangle saying you could extend this to sampling from a polygon by dividing the polygon into triangles, and selecting a triangle each time with probability proportional to the triangle's area.

To illustrate this, let's start with a irregular pentagon.

sample_poly1.png

To pick a point inside, I used the centroid, the average of the vertices. Connecting the centroid to each of the vertices splits the pentagon into triangles. (Here I implicitly used the fact that this pentagon is convex. The centroid of a non-convex polygon could be outside the polygon.)

sample_poly2.png

We can find the area of the triangles using Heron's rule.

Here's what we get for random samples.

sample_poly3.png

The post Random samples from a polygon first appeared on John D. Cook.
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments