Learn R Programming

spatstat (version 1.64-1)

rlpp: Random Points on a Linear Network

Description

Generates \(n\) independent random points on a linear network with a specified probability density.

Usage

rlpp(n, f, …, nsim=1, drop=TRUE)

Arguments

n

Number of random points to generate. A nonnegative integer giving the number of points, or an integer vector giving the numbers of points of each type.

f

Probability density (not necessarily normalised). A pixel image on a linear network (object of class "linim") or a function on a linear network (object of class "linfun"). Alternatively, f can be a list of functions or pixel images, giving the densities of points of each type.

Additional arguments passed to f if it is a function or a list of functions.

nsim

Number of simulated realisations to generate.

drop

Logical value indicating what to do when nsim=1. If drop=TRUE (the default), the result is a point pattern. If drop=FALSE, the result is a list with one entry which is a point pattern.

Value

If nsim = 1 and drop=TRUE, a point pattern on the linear network, i.e.\ an object of class "lpp". Otherwise, a list of such point patterns.

Details

The linear network L, on which the points will be generated, is determined by the argument f.

If f is a function, it is converted to a pixel image on the linear network, using any additional function arguments .

If n is a single integer and f is a function or pixel image, then independent random points are generated on L with probability density proportional to f.

If n is an integer vector and f is a list of functions or pixel images, where n and f have the same length, then independent random points of several types are generated on L, with n[i] points of type i having probability density proportional to f[[i]].

See Also

runiflpp

Examples

Run this code
# NOT RUN {
  g <- function(x, y, seg, tp) { exp(x + 3*y) }
  f <- linfun(g, simplenet)

  rlpp(20, f)

  plot(rlpp(20, f, nsim=3))
# }

Run the code above in your browser using DataLab