swh:1:snp:3a44eb759780145deea094ac2a25c5049546a085
Tip revision: c52ce072e457ea91212cea8cbcace0daa866910b authored by Han Lin Shang on 07 October 2018, 07:10:02 UTC
version 5.1
version 5.1
Tip revision: c52ce07
metri.p.R
metri.p <- function(x1, x2, p = 2, w = 1)
{
if (length(x1) != length(x2))
stop("Dimensions of matrices do not match\n")
if (length(w) == 1)
w = rep(w,length(x1))
if (length(w) != length(x1))
stop("Length of the vector does not match with the matrix\n")
if (p > 0){
(sum(w * (abs(x1 - x2) ^ p))) ^ (1/p)
}
else {
max(w * abs(x1 - x2))
}
}