minkowski: Minkowski distance

Description Usage Arguments Value Examples

View source: R/metrics.minkowski.R

Description

Compute Minkowski distance between two dataset or SparseHist X and Y. If p = 2, it is the Euclidean distance, for p = 1, it is the manhattan distance, if p = Inf, chebyshev distance is called.

Usage

1
minkowski(X, Y, p = 2)

Arguments

X

[matrix or SparseHist] If matrix, dim = ( nrow = n_samples, ncol = n_features)

Y

[matrix or SparseHist] If matrix, dim = ( nrow = n_samples, ncol = n_features)

p

[float] power of distance

Value

[float] value of distance

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
X = base::cbind( stats::rnorm(2000) , stats::rnorm(2000)  )
Y = base::cbind( stats::rnorm(2000,mean=2)  , stats::rnorm(2000) )
bw = base::c(0.1,0.1)
muX = SBCK::SparseHist( X , bw )
muY = SBCK::SparseHist( Y , bw )

## The four are equals
d = SBCK::minkowski(  X ,   Y , p = 3 )
d = SBCK::minkowski(muX ,   Y , p = 3 )
d = SBCK::minkowski(  X , muY , p = 3 )
d = SBCK::minkowski(muX , muY , p = 3 )

SBCK documentation built on April 10, 2021, 9:06 a.m.

Related to minkowski in SBCK...