Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

total.dist

Sum of all pairwise distances in a distance matrix


Description

Sum of all pairwise distances in a distance matrix.

Usage

total.dist(x, method = "euclidean", square = FALSE, p = 0)
total.dista(x, y, square = FALSE)

Arguments

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.

Details

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.

Value

A numerical value, the sum of the distances.

Author(s)

Manos Papadakis

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.

See Also

Examples

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

Rfast

A Collection of Efficient and Extremely Fast R Functions

v2.0.1
GPL (>= 2.0)
Authors
Manos Papadakis, Michail Tsagris, Marios Dimitriadis, Stefanos Fafalios, Ioannis Tsamardinos, Matteo Fasiolo, Giorgos Borboudakis, John Burkardt, Changliang Zou, Kleanthi Lakiotaki and Christina Chatzipantsiou.
Initial release
2020-09-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.