[R] quasi-random sequences

From: <adrian_at_maths.uwa.edu.au>
Date: Mon, 28 Apr 2008 11:25:29 +0800 (WST)

Baptiste Augui? writes:

> I have to generate a random set of coordinates (x,y) in [-1 ; 1]^2
> for say, N points.
> [...]
> My problem is to avoid collisions (overlap, really) between the
> points. I would like some random pattern, but with a minimum
> exclusion distance.

As Brian Ripley has mentioned, there are several algorithms available in the contributed packages for spatial statistics, particularly 'spatial', 'splancs' and 'spatstat'.

For example in the 'spatstat' package you could try the following algorithms which generate random point patterns that respect a 'hard core' (i.e. no points ever come closer than the specified distance):

      rSSI    Simple Sequential Inhibition
              (places points randomly one-at-a-time)

      rMaternI
      rMaternII  Matern Inhibition processes
                 (places points randomly, then deletes offending points)

      rstrat   Stratified random sampling
               (divides region into squares, then places N points
               in each square; use N=1)

The following algorithms generate point patterns with a `soft core' (tendency to avoid placing points close together):

      rStrauss    Strauss point process
                  (inhibition parameter gamma controls 'softness' of core)

      rmh         Metropolis-Hastings simulation algorithm
                  (various choices of model)

You can also generate a regular grid of points (randomly shifted) and then randomly perturb each point:

       library(spatstat)
       W <- owin(c(-1,1),c(-1,1))
       X <- rstrat(W, nx=10, ny=10, k=1)
       X <- rshift(X, group=factor(seq(X$n)), radius=0.05, edge="torus")
       plot(X)

Adrian Baddeley



R-help_at_r-project.org 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. Received on Mon 28 Apr 2008 - 03:45:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 Apr 2008 - 08:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive