pairwise_distances: Pairwise distances

View source: R/tools.Pairwise_distances.R

pairwise_distancesR Documentation

Pairwise distances

Description

Compute the matrix of pairwise distances between a matrix X and a matrix Y

Usage

pairwise_distances(X,Y,metric)

Arguments

X

[matrix] A first matrix (samples in row, features in columns).

Y

[matrix] A second matrix (samples in row, features in columns). If Y = NULL, then pairwise distances is computed between X and X

metric

[string or callable] The metric used. If metric is a string, then metric is compiled (so faster). Available string are: "euclidean", "sqeuclidean" (Square of Euclidean distance), "logeulidean" (log of the Euclidean distance) and "chebyshev" (max). Callable must be a function taking two vectors and returning a double.

Value

distXY [matrix] Pairwise distances. distXY[i,j] is the distance between X[i,] and Y[j,]

Examples

X = matrix( stats::rnorm(200) , ncol = 100 , nrow = 2 )
Y = matrix( stats::rexp(300)  , ncol = 150 , nrow = 2 )

distXY = SBCK::pairwise_distances( X , Y ) 


SBCK documentation built on Sept. 11, 2023, 5:10 p.m.