Description Usage Arguments Value See Also Examples
This function checks whether the distance matrix D:=d_{ij} = d(x_i, x_j) satisfies four axioms to make itself a semimetric, which are (1) d_{ii} = 0, (2) d_{ij} > 0 for i\neq j, (3) d_{ij} = d_{ji}, and (4) d_{ij} ≤q d_{ik} + d_{kj}.
1 | checkmetric(d)
|
d |
|
a logical; TRUE
if it satisfies metric property, FALSE
otherwise.
1 2 3 4 5 6 7 8 9 10 11 | ## Let's use L2 distance matrix of iris dataset
data(iris)
dx = as.matrix(stats::dist(iris[,1:4]))
# perturb d(i,j)
dy = dx
dy[1,2] <- dy[2,1] <- 10
# run the algorithm
checkmetric(dx)
checkmetric(dy)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.