Uniform sampling of is the problem of generating random samples from with a uniform distribution.
In the following we assume that we are able to uniformly sample a real interval. A general algorithm to uniformly sample any set is to bound it with an axis-aligned box , draw samples from a uniform distribution on , and accept only those samples which are also in . This is called rejection sampling. The probability that a sample drawn from is also in is the ratio of the measures of and . Thus the efficiency is highly dependent on this ratio. Unfortunately, this ratio is often low, or even zero. For example, uniformly sampling the surface of a sphere in would not succeed using rejection sampling in the described manner.
Thus, more than often it is either necessary, or much more efficient, to generate uniform samplings via slightly more complex algorithms. Pastel implements efficient algorithms to uniform sample from:
If instead you need to distort an existing uniform sampling from one shape to another, see the link below.