Ranjan Maitra writes:

> Does anyone have a suggestion (or better still) code for sampling
> from the uniform distribution over the convex hull of a set of
> points?

This is implemented in library 'spatstat'.

If x and y are vectors of coordinates of your initial set of points,

   library(spatstat)

   W <- convexhull.xy(x, y)
   
   P <- runifpoint(42, W)

will compute the convex hull and generate 42 independent 
uniformly-distributed points in the convex hull.

The result can be plotted by 
    plot(P)
and the coordinates of the simulated points can be extracted
as P$x and P$y.

Adrian Baddeley

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to