# rpoispp

##### Generate Poisson Point Pattern

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

##### Usage

`rpoispp(lambda, lmax=NULL, win=owin(), ..., nsim=1, drop=TRUE)`

##### Arguments

- lambda
- Intensity of the Poisson process.
Either a single positive number, a
`function(x,y, ...)`

, or a pixel image. - lmax
- An upper bound for the value of
`lambda(x,y)`

, if`lambda`

is a function. - win
- 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. - nsim
- Number of simulated realisations to be generated.
- drop
- Logical. If
`nsim=1`

and`drop=TRUE`

(the default), the result will be a point pattern, rather than a list containing a point pattern.

##### Details

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`

.

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.
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`

.

##### Value

- A point pattern (an object of class
`"ppp"`

) if`nsim=1`

, or a list of point patterns if`nsim > 1`

.

##### Warning

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`

.

##### 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`

.

##### Examples

```
# 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))
```

*Documentation reproduced from package spatstat, version 1.41-1, License: GPL (>= 2)*