ipd.mat.euc: Euclidean Interpoint Distance Matrix In nnspat: Nearest Neighbor Methods for Spatial Patterns

Description

Returns the Euclidean interpoint distance (IPD) matrix of a given the set of points `x` and `y` using two for loops with the `euc.dist` function of the current package. If `y` is provided (default=`NULL`) it yields a matrix of Euclidean distances between the rows of `x` and rows of `y`, otherwise it provides a square matrix with i,j-th entry being the Euclidean distance between row i and row j of `x`. This function is different from the `ipd.mat` function in this package. `ipd.mat` returns the full distance matrix for a variety of distance metrics (including the Euclidean metric), while `ipd.mat.euc` uses the Euclidean distance metric only. `ipd.mat.euc(X)` and `ipd.mat(X)` yield the same output for a set of points `X`, as the default metric in `ipd.mat` is also `"euclidean"`.

Usage

 `1` ```ipd.mat.euc(x, y = NULL) ```

Arguments

 `x` A set of points in matrix or data frame form where points correspond to the rows. `y` A set of points in matrix or data frame form where points correspond to the rows (default=`NULL`).

Value

A distance matrix whose i,j-th entry is the Euclidean distance between row i of `x` and row j of `y` if `y` is provided, otherwise i,j-th entry is the Euclidean distance between rows i and j of `x`.

Elvan Ceyhan

See Also

`dist`, `ipd.mat.euc`, `dist.std.data`

Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21``` ```#3D data points n<-3 X<-matrix(runif(3*n),ncol=3) ipd.mat.euc(X) n<-5 Y<-matrix(runif(3*n),ncol=3) ipd.mat.euc(X,Y) ipd.mat.euc(X[1,],Y) ipd.mat.euc(c(.1,.2,.3),Y) ipd.mat.euc(X[1,],Y[3,]) #1D data points X<-as.matrix(runif(3)) # need to be entered as a matrix with one column #(i.e., a column vector), hence X<-runif(3) would not work ipd.mat.euc(X) Y<-as.matrix(runif(5)) ipd.mat.euc(X,Y) ipd.mat.euc(X[1,],Y) ipd.mat.euc(X[1,],Y[3,]) ```

nnspat documentation built on May 10, 2021, 9:06 a.m.