gdist: Pairwise distance between groups

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/interfaces.R

Description

dist computes distances between pairs of elements: gdist takes two arguments, and returns the matrix of distances wrt every possible pair with one argument from each group. General Mahalanobis metrics are also allowed.

Usage

1
gdist(g1, g2, metric = NULL, norm=FALSE)

Arguments

g1

n1 x d matrix with n1 data elements.

g2

n2 x d matrix with n2 data elements.

metric

If NULL, defaults to identity (i.e. Euclidean distance). A d x d matrix is assumed as a sample covariance matrix, and its inverse is used to compute distances (i.e. Mahalanobis distance). Likewise, a list of n2 d x d matrices can be provided, yielding distances specific to each row in g2.

norm

If TRUE, a ln det term is added to distances in order to mitigate the prevalence of metrics reflecting large variance.

Details

This function is especially useful to make algorithms such as k-means (or mkmeans in the package) more efficient - rows in g1 are then generally the data set, and in g2 respectively cluster centres.

Value

n1 x n2 matrix of distances

Author(s)

P. Bruneau

See Also

dist, mkmeans

Examples

1
dists <- gdist(irisdata, irisdata[c(1,11,21),])

VBmix documentation built on May 30, 2017, 2:34 a.m.

Related to gdist in VBmix...