Learn R Programming

TDA (version 1.6.2)

distFct: Distance function

Description

The function distFct computes the distance between each point of a set Grid and the corresponding closest point of another set X.

Usage

distFct(X, Grid)

Arguments

X

a numeric \(m\) by \(d\) matrix of coordinates in the space, where \(m\) is the number of points in X and \(d\) is the dimension of the space.

Grid

a numeric \(n\) by \(d\) matrix of coordinates in the space, where \(n\) is the number of points in Grid and \(d\) is the dimension of the space.

Value

The function distFct returns a numeric vector of length \(n\), where \(n\) is the number of points stored in Grid.

Details

Given a set of points X, the distance function computed at \(g\) is defined as $$ d(g) = \inf_{x \in X} \| x-g \|_2 $$

See Also

kde,kernelDist, dtm

Examples

Run this code
# NOT RUN {
## Generate Data from the unit circle
n <- 300
X <- circleUnif(n)

## Construct a grid of points over which we evaluate the function
by <- 0.065
Xseq <- seq(-1.6, 1.6, by = by)
Yseq <- seq(-1.7, 1.7, by = by)
Grid <- expand.grid(Xseq, Yseq)

## distance fct
distance <- distFct(X, Grid)
# }

Run the code above in your browser using DataLab