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`

.