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 |
|
method |
distance measure, "maximum", "cosine", or "euclidean" are implemented. |
Value
a list
of four components:
dist |
|
match |
|
value |
|
method |
|
nrow |
|
See Also
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")