subset of a uniform random number.

78 Views Asked by At

I need to create a 2-D random number generator that generates numbers in a convex region. Say, for example, this region falls within the area [-1,1]2. Would the following process lead to a uniform generator of points within the convex region?

1: generate a number in [-1,1]2, say x

2: if x is in the convex region, return x else repeat 1

It feels like it should, I just want to confirm that I'm not creating some weird dependency.

P.S. I realize this is very inefficient, but the region is not something I will know beforehand.

1

There are 1 best solutions below

2
On BEST ANSWER

The uniform measure on the convex region is by definition the (normalized) restriction of Lebesgue measure on the unit square. Therefore your approach is correct on the condition that the convex region has positive measure itself.