I am trying to generate two dimensional random coordinates. For randomly distributed data I have simply used>xy<-cbind(runif(100),runif(100))However I also want to generate coordinates that are more uniformly distributed, and coordinates that are more contagiously distributed than the above. Can anyone make any suggestions Thanks. Dr Terry Beutel Rangeland Scientist Animal Sciences Department of Primary Industries and Fisheries Telephone 07 4654 4282 Facsimile 07 4654 4235 Email terry.beutel@dpi.qld.gov.au Address DPI Hood Street Charleville Q 4470 PO Box 282, Charleville Q 4470 Website www.dpi.qld.gov.au Call Centre 13 25 23 ********************************DISCLAIMER******************...{{dropped}}
Dear Terry, I'm not entirely sure if this is what you're looking for, but here's my suggestion. To make more uniformly distributed points, you might try something like xy <- expand.grid(list(seq(0,1,.1), seq(0,1,.1))) plot(jitter(xy[,1], 1.5), jitter(xy[,2], 1.5)) Like I said, I don't know if this is any better. For the clumped data, I would suggest a something like draws out of two different normals, something like this: xy1 <- matrix(rnorm(250, .6, .25), ncol=2) xy2 <- matrix(rnorm(250, -.6, .25), ncol=2) xy12 <- rbind(xy1, xy2) plot(xy12) The sd of the normal controls the "clumpiness" of the data. Hope this helps, Dave. -- Dave Armstrong University of Maryland Dept of Government and Politics 3140 Tydings Hall College Park, MD 20742 Office: 2103L Cole Field House Phone: 301-405-9735 e-mail: darmstrong@gvpt.umd.edu web: www.davearmstrong-ps.com On 5/17/06, Beutel, Terry S <Terry.Beutel@dpi.qld.gov.au> wrote:> > I am trying to generate two dimensional random coordinates. > > For randomly distributed data I have simply used > > >xy<-cbind(runif(100),runif(100)) > > However I also want to generate coordinates that are more uniformly > distributed, and coordinates that are more contagiously distributed than > the above. > > Can anyone make any suggestions > > Thanks. > > Dr Terry Beutel > Rangeland Scientist > Animal Sciences > Department of Primary Industries and Fisheries > > Telephone 07 4654 4282 Facsimile 07 4654 4235 > Email terry.beutel@dpi.qld.gov.au > Address DPI Hood Street Charleville Q 4470 > PO Box 282, Charleville Q 4470 > Website www.dpi.qld.gov.au Call Centre 13 25 23 > > > ********************************DISCLAIMER******************...{{dropped}} > > ______________________________________________ > R-help@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 >[[alternative HTML version deleted]]
Beutel, Terry S <Terry.Beutel <at> dpi.qld.gov.au> writes:> > I am trying to generate two dimensional random coordinates. > > For randomly distributed data I have simply used > > >xy<-cbind(runif(100),runif(100)) > > However I also want to generate coordinates that are more uniformly > distributed, and coordinates that are more contagiously distributed than > the above. > >here are some pictures I made for a talk recently, using the Poisson cluster process function from "splancs" and the Strauss process from "spatial" (I think) library(splancs) library(spatial) set.seed(1001) sq <- as.matrix(data.frame(x=c(0,1,1,0,0),y=c(0,0,1,1,0))) p.cl <- pcp.sim(rho=10,m=10,s2=0.001,region.poly=sq) plot(p.cl) n <- nrow(p.cl) p.ran <- matrix(runif(2*n),nrow=n,dimnames=list(NULL,c("x","y"))) ppregion() p.reg <- Strauss(n,c=0.1,r=0.1) p.reg <- matrix(c(p.reg$x,p.reg$y),nrow=n,dimnames=list(NULL,c("x","y"))) all <- data.frame(rbind(p.cl,p.ran,p.reg), tr=rep(c("clustered","random","regular"),each=n)) library(lattice) lattice.options(default.theme = ltheme) ## set as default ltheme <- col.whitebg() ltheme$xyplot.background$col <- "transparent" ## change strip bg trellis.par.set(theme=col.whitebg()) print(xyplot(y~x|tr,data=all,layout=c(3,1),aspect="iso",scales=list(draw=FALSE), bg="transparent",pch=16)) Ben Bolker
Beutel, Terry S wrote: > > I am trying to generate two dimensional random coordinates. > > For randomly distributed data I have simply used > > >xy<-cbind(runif(100),runif(100)) > > However I also want to generate coordinates that are more uniformly > distributed, and coordinates that are more contagiously distributed > than the above. Hi Terry, Not sure exactly what you are trying to do, but if you want to space out overlying points, you might find cluster.overplot in the plotrix package useful. On the other hand, if you want coordinate pairs that are more evenly spaced, maybe something like this: xy<-cbind(sample(seq(0,1,length=101),100,TRUE), sample(seq(0,1,length=101),100,TRUE)) Jim PS Did you mean "contiguously"?
Dear Terry the R package 'spatstat' contains a large number of functions for generating point patterns with varying degrees of randomness or orderliness. They include: rpoint n independent random points rpoispp random number of independent random points rstrat stratified random pattern (k points in each box) rsyst systematic random pattern (randomly placed grid) rThomas Thomas cluster model rMatClust Matern Cluster model rNeymanScott Neyman-Scott cluster model rcell Baddeley-Silverman cell process rmh Gibbs point processes (Strauss, Geyer etc) Several of your correspondents have suggested using the normal distribution to make clumps of points. This is what the `Thomas' model does - it first generates a random pattern of centre points, then around each centre, it generates a clump of points with Normally distributed displacements from the centre point. The Matern cluster model is a similar thing, but instead of the points being Normally distributed around each centre, they are uniformly distributed inside a circle around the centre point. One of the replies suggested using the Strauss process. This does not produce clumps. You can get weakly clumped point patterns from the Geyer process and some of the other Gibbs processes offered in 'rmh', but in general this is not the best way to create clumps. Hope this helps Adrian Baddeley