dist.matrix {epca}R Documentation

Matrix Column Distance

Description

Compute the distance between two matrices. The distance between two matrices is defined as the sum of distances between column pairs. This function matches the columns of two matrices, such that the matrix distance (i.e., the sum of paired column distances) is minimized. This is accomplished by solving an optimization over column permutation. Given two matrices, x and y, find permutation p() that minimizes sum_i similarity(⁠x[,p(i)], y[,i]⁠), where the similarity() can be "euclidean" distance, 1 - "cosine", or "maximum" difference (manhattan distance). The solution is computed by clue::solve_LSAP().

Usage

dist.matrix(x, y, method = "euclidean")

Arguments

x, y

matrix or Matrix, of the same number of rows. The columns of x and y will be scaled to unit length.

method

distance measure, "maximum", "cosine", or "euclidean" are implemented.

Value

a list of four components:

dist

dist, the distance matrix.

match

solve_LSAP, the column matches.

value

numeric vector, the distance between pairs of columns.

method

character, the distance measure used.

nrow

integer, the dimension of the input matrices, i.e., nrow(x).

See Also

clue::solve_LSAP

Examples

x <- diag(4)
y <- x + rnorm(16, sd = 0.05) # add some noise
y = t(t(y) / sqrt(colSums(y ^ 2))) ## normalize the columns
## euclidian distance between column pairs, with minimal matches
dist.matrix(x, y, "euclidean")


[Package epca version 1.1.0 Index]