rpoispp | R Documentation |
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,
forcewin=FALSE, warnwin=TRUE)
lambda |
Intensity of the Poisson process.
Either a single positive number, a |
lmax |
Optional. An upper bound for the value of |
win |
Window in which to simulate the pattern.
An object of class |
... |
Arguments passed to |
nsim |
Number of simulated realisations to be generated. |
drop |
Logical. If |
ex |
Optional. A point pattern to use as the example.
If |
forcewin |
Logical value specifying whether to use the argument |
warnwin |
Logical value specifying whether to issue a warning
when |
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.)
If forcewin=FALSE
(the default),
the simulation window will be the window of the pixel image
(converted to a rectangle if possible
using rescue.rectangle
).
If forcewin=TRUE
, the simulation window will be the argument
win
.
For marked point patterns, use rmpoispp
.
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.
The previous slower 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}
.
The new faster algorithm randomly selects pixels with
probability proportional to intensity, and generates point locations
inside the selected pixels.
Thinning is still used when lambda
is a function(x,y,...)
.
.
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
.
# 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 <- as.im(function(x,y){100 * sqrt(x+y)}, unit.square())
pp <- rpoispp(Z)
# randomising an existing point pattern
rpoispp(intensity(cells), win=Window(cells))
rpoispp(ex=cells)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.