Adrian Baddeley
2007-Mar-26 02:05 UTC
[R] sampling from the uniform distribution over a convex hull
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
(Ted Harding)
2007-Mar-26 10:31 UTC
[R] sampling from the uniform distribution over a convex hu
I just wrote:> Thanks, Adrian! I should have remembered about 'spatstat' after > the Baddeley et al. paper to the RSS in June 2005, where the > package was extensively used! (Though neither convexhull() nor > runifpoint() are in the package I downloaded at the time; but of > course things have moved on!).Apologies -- that last statement is false! Ted.
Ranjan Maitra
2007-Mar-26 13:37 UTC
[R] sampling from the uniform distribution over a convex hu
Thanks, all, and thanks especially to Ted for your investigations in the other thread with the same title! Does spatstat handle higher dimensions than 2? Best wishes, Ranjan On Mon, 26 Mar 2007 10:31:15 -0000 (BST) (Ted Harding) <ted.harding at nessie.mcc.ac.uk> wrote:> I just wrote: > > > Thanks, Adrian! I should have remembered about 'spatstat' after > > the Baddeley et al. paper to the RSS in June 2005, where the > > package was extensively used! (Though neither convexhull() nor > > runifpoint() are in the package I downloaded at the time; but of > > course things have moved on!). > > Apologies -- that last statement is false! > Ted. > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >