Learn R Programming

spatstat (version 1.52-1)

rpoisppOnLines: Generate Poisson Point Pattern on Line Segments

Description

Given a line segment pattern, generate a Poisson random point pattern on the line segments.

Usage

rpoisppOnLines(lambda, L, lmax = NULL, ..., nsim=1)

Arguments

lambda

Intensity of the Poisson process. A single number, a function(x,y), a pixel image (object of class "im"), or a vector of numbers, a list of functions, or a list of images.

L

Line segment pattern (object of class "psp") on which the points should be generated.

lmax

Optional upper bound (for increased computational efficiency). A known upper bound for the values of lambda, if lambda is a function or a pixel image. That is, lmax should be a number which is known to be greater than or equal to all values of lambda.

Additional arguments passed to lambda if it is a function.

nsim

Number of simulated realisations to be generated.

Value

If nsim = 1, a point pattern (object of class "ppp") in the same window as L. If nsim > 1, a list of such point patterns.

Details

This command generates a Poisson point process on the one-dimensional system of line segments in L. The result is a point pattern consisting of points lying on the line segments in L. The number of random points falling on any given line segment follows a Poisson distribution. The patterns of points on different segments are independent.

The intensity lambda is the expected number of points per unit length of line segment. It may be constant, or it may depend on spatial location.

In order to generate an unmarked Poisson process, the argument lambda may be a single number, or a function(x,y), or a pixel image (object of class "im").

In order to generate a marked Poisson process, lambda may be a numeric vector, a list of functions, or a list of images, each entry giving the intensity for a different mark value.

If lambda is not numeric, then the (Lewis-Shedler) rejection method is used. The rejection method requires knowledge of lmax, the maximum possible value of lambda. This should be either a single number, or a numeric vector of the same length as lambda. If lmax is not given, it will be computed approximately, by sampling many values of lambda.

If lmax is given, then it must be larger than any possible value of lambda, otherwise the results of the algorithm will be incorrect.

See Also

psp, ppp, runifpointOnLines, rpoispp

Examples

Run this code
# NOT RUN {
  live <- interactive()
  L <- psp(runif(10), runif(10), runif(10), runif(10),  window=owin())
  if(live) plot(L, main="")

  # uniform intensity
  Y <- rpoisppOnLines(4, L)
  if(live) plot(Y, add=TRUE, pch="+")

  # uniform MARKED process with types 'a' and 'b'
  Y <- rpoisppOnLines(c(a=4, b=5), L)
  if(live) {
    plot(L, main="")
    plot(Y, add=TRUE, pch="+")
  }

  # intensity is a function
  Y <- rpoisppOnLines(function(x,y){ 10 * x^2}, L, 10)
  if(live) { 
    plot(L, main="")
    plot(Y, add=TRUE, pch="+")
  }

  # intensity is an image
  Z <- as.im(function(x,y){10 * sqrt(x+y)}, unit.square())
  Y <- rpoisppOnLines(Z, L, 15)
  if(live) {
   plot(L, main="")
   plot(Y, add=TRUE, pch="+")
  }
# }

Run the code above in your browser using DataLab