ppdistnet {ttbary}R Documentation

Compute Distance Between Two Point Patterns on a Network

Description

Based on an arbitrary matrix of "distances" on a network, this function computes versions of the transport-transform distance between two point patterns \xi and \eta on this network.

Usage

ppdistnet(
  dmat,
  xi = NULL,
  eta = NULL,
  penalty = 1,
  type = c("tt", "rtt", "TT", "RTT"),
  ret_matching = FALSE,
  p = 1,
  precision = NULL
)

Arguments

dmat

a matrix specifying in its (i,j)-th entry the shortest-path distance from the i-th point of \xi to the j-th point of \eta OR the distance matrix of a whole network. In the latter case arguments \xi and \eta have to be specified.

xi

a vector specifying the vertex-indices of \xi, only needed if dmat is the distance matrix of a whole network.

eta

a vector specifying the vertex-indices of \eta, only needed if dmat is the distance matrix of a whole network.

penalty

a positive number. The penalty for adding/deleting points.

type

either "tt"/"TT" for the transport-transform metric or "rtt"/"RTT" for the relative transport-transform metric.

ret_matching

Logical. Shall the optimal point matching be returned?

p

a number >0. The matching is chosen such that the p-th order sum (\ell_p-norm) is minimized.

precision

a small positive integer value. The precision of the computations, which are currently performed in integers. After correcting for the penalty, dmat^p is divided by its largest entry, multiplied by 10^precision and rounded to compute the optimal matching. The default value NULL chooses maximal integer precision possible, which is precision = 9 on almost all systems.

Details

This function provides a more convenient way for computing (relative) transport-transform distances on networks if the points of the patterns are given in terms of indices of network vertices. If dmat contains only the distances between the points of \xi and \eta, this function does the same as ppdist.

Value

The corresponding distance between the point patterns if ret_matching is FALSE.

Otherwise a list with components dist containing this distance and two vectors target1, target2 of integers, where targeti specifies the indices of the points in the other pattern that the points of the i-th pattern are matched to and NA every time a point is deleted.

There may be a minus in front of an index, where -j indicates that the corresponding pairing with point j would be over a distance of more than 2^{1/p} \cdot \code{penalty}. This is equivalent to saying that the corresponding point of the first pattern is deleted and the j-th point of the second pattern is added.

Note that having more than one minus implies that the matching is non-unique.

Author(s)

Raoul Müller raoul.mueller@uni-goettingen.de
Dominic Schuhmacher schuhmacher@math.uni-goettingen.de

See Also

ppdist

Examples

  set.seed(123456)
  nvert <- 100 #number of vertices in the network
  lambda <- 0.5 #expected number of points per unit length
  ln <- delaunayNetwork(runifpoint(nvert)) #create an artificial network
  ppnetwork <- rpoislpp(lambda, ln, nsim = 2)
    #simulate two point patterns on the network

  plot(ppnetwork[[1]]$domain, cex=0.5, main="")
  plot(as.ppp(ppnetwork[[1]]),vpch=1,col=2,add=TRUE)
  plot(as.ppp(ppnetwork[[2]]),vpch=1,col=4,add=TRUE)

  res <- netsplit(ln, ppnetwork)
    #incorporate data point patterns into the network
    #calculating all pairwise distances between vertices
    #and creating matrix of vertex-indices of data point patterns
  
  xi <- res$ppmatrix[1:npoints(ppnetwork[[1]]), 1]
  eta <- res$ppmatrix[1:npoints(ppnetwork[[2]]), 2]
  res2 <- ppdistnet(res$network$dpath, xi = xi, eta = eta,
                    penalty = 1, type = "tt", ret_matching = TRUE, p = 1)
  res2


[Package ttbary version 0.3-1 Index]