minkowski {SBCK} | R Documentation |
Minkowski distance
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
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
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 )
[Package SBCK version 1.0.0 Index]