ipd.mat.euc {nnspat}R Documentation

Euclidean Interpoint Distance Matrix

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

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.

Author(s)

Elvan Ceyhan

See Also

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

Examples

#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,])


[Package nnspat version 0.1.2 Index]