Sum of all pairwise distances in a distance matrix
Sum of all pairwise distances in a distance matrix.
total.dist(x, method = "euclidean", square = FALSE, p = 0) total.dista(x, y, square = FALSE)
x |
A matrix with numbers. |
y |
A second matrix with data. The number of comlumns of this matrix must be the same with the matrix x. The number of rows can be different. |
method |
This is either "euclidean", "manhattan", "canberra1", "canberra2", "minimum", "maximum", "minkowski","bhattacharyya", "hellinger", "total_variation" or "kullback_leibler/jensen_shannon". The last two options are basically the same. |
square |
If you choose "euclidean" or "hellinger" as the method, then you can have the option to return the squared Euclidean distances by setting this argument to TRUE. |
p |
This is for the the Minkowski, the power of the metric. |
In order to do the total.dist one would have to calcualte the distance matrix and sum it. We do this internally in C++ without creating the matrix. For the total.dista it is the same thing.
A numerical value, the sum of the distances.
Manos Papadakis
R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.
x <- matrix( rnorm(50 * 10), ncol = 10 ) res<-total.dist(x) y <- matrix( rnorm(40 * 10), ncol = 10) res<-total.dista(x, y) res<-total.dista(y, x) x<-y<-NULL
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.