[R] quasi-random sequences
adrian at maths.uwa.edu.au
adrian at maths.uwa.edu.au
Mon Apr 28 05:25:29 CEST 2008
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
More information about the R-help
mailing list