spatstat (version 1.64-1)

rpoispp: Generate Poisson Point Pattern


Generate a random point pattern using the (homogeneous or inhomogeneous) Poisson process. Includes CSR (complete spatial randomness).


rpoispp(lambda, lmax=NULL, win=owin(), …,
         nsim=1, drop=TRUE, ex=NULL, warnwin=TRUE)



Intensity of the Poisson process. Either a single positive number, a function(x,y, …), or a pixel image.


Optional. An upper bound for the value of lambda(x,y), if lambda is a function.


Window in which to simulate the pattern. An object of class "owin" or something acceptable to as.owin. Ignored if lambda is a pixel image.

Arguments passed to lambda if it is a function.


Number of simulated realisations to be generated.


Logical. If nsim=1 and drop=TRUE (the default), the result will be a point pattern, rather than a list containing a point pattern.


Optional. A point pattern to use as the example. If ex is given and lambda,lmax,win are missing, then lambda and win will be calculated from the point pattern ex.


Logical value specifying whether to issue a warning when win is ignored (which occurs when lambda is an image and win is present).


A point pattern (an object of class "ppp") if nsim=1, or a list of point patterns if nsim > 1.


Note that lambda is the intensity, that is, the expected number of points per unit area. The total number of points in the simulated pattern will be random with expected value mu = lambda * a where a is the area of the window win.


The simulation algorithm, for the case where lambda is a pixel image, was changed in spatstat version 1.42-3. Set spatstat.options(fastpois=FALSE) to use the previous, slower algorithm, if it is desired to reproduce results obtained with earlier versions.


If lambda is a single number, then this algorithm generates a realisation of the uniform Poisson process (also known as Complete Spatial Randomness, CSR) inside the window win with intensity lambda (points per unit area).

If lambda is a function, then this algorithm generates a realisation of the inhomogeneous Poisson process with intensity function lambda(x,y,…) at spatial location (x,y) inside the window win. The function lambda must work correctly with vectors x and y.

If lmax is given, it must be an upper bound on the values of lambda(x,y,…) for all locations (x, y) inside the window win. That is, we must have lambda(x,y,…) <= lmax for all locations (x,y). If this is not true then the results of the algorithm will be incorrect.

If lmax is missing or NULL, an approximate upper bound is computed by finding the maximum value of lambda(x,y,…) on a grid of locations (x,y) inside the window win, and adding a safety margin equal to 5 percent of the range of lambda values. This can be computationally intensive, so it is advisable to specify lmax if possible.

If lambda is a pixel image object of class "im" (see im.object), this algorithm generates a realisation of the inhomogeneous Poisson process with intensity equal to the pixel values of the image. (The value of the intensity function at an arbitrary location is the pixel value of the nearest pixel.) The argument win is ignored; the window of the pixel image is used instead. It will be converted to a rectangle if possible, using rescue.rectangle.

To generate an inhomogeneous Poisson process the algorithm uses ``thinning'': it first generates a uniform Poisson process of intensity lmax, then randomly deletes or retains each point, independently of other points, with retention probability \(p(x,y) = \lambda(x,y)/\mbox{lmax}\).

For marked point patterns, use rmpoispp.

See Also

rmpoispp for Poisson marked point patterns, runifpoint for a fixed number of independent uniform random points; rpoint, rmpoint for a fixed number of independent random points with any distribution; rMaternI, rMaternII, rSSI, rStrauss, rstrat for random point processes with spatial inhibition or regularity; rThomas, rGaussPoisson, rMatClust, rcell for random point processes exhibiting clustering; rmh.default for Gibbs processes. See also ppp.object, owin.object.


Run this code
 # uniform Poisson process with intensity 100 in the unit square
 pp <- rpoispp(100)
 # uniform Poisson process with intensity 1 in a 10 x 10 square
 pp <- rpoispp(1, win=owin(c(0,10),c(0,10)))
 # plots should look similar !
 # inhomogeneous Poisson process in unit square
 # with intensity lambda(x,y) = 100 * exp(-3*x)
 # Intensity is bounded by 100
 pp <- rpoispp(function(x,y) {100 * exp(-3*x)}, 100)

 # How to tune the coefficient of x
 lamb <- function(x,y,a) { 100 * exp( - a * x)}
 pp <- rpoispp(lamb, 100, a=3)

 # pixel image
 Z <-,y){100 * sqrt(x+y)}, unit.square())
 pp <- rpoispp(Z)

 # randomising an existing point pattern
 rpoispp(intensity(cells), win=Window(cells))
# }

Run the code above in your browser using DataLab