checkmetric {maotai}R Documentation

Check for Metric Matrix

Description

This function checks whether the distance matrix D:=dij=d(xi,xj)D:=d_{ij} = d(x_i, x_j) satisfies four axioms to make itself a semimetric, which are (1) dii=0d_{ii} = 0, (2) dij>0d_{ij} > 0 for iji\neq j, (3) dij=djid_{ij} = d_{ji}, and (4) dijdik+dkjd_{ij} \leq d_{ik} + d_{kj}.

Usage

checkmetric(d)

Arguments

d

"dist" object or (N×N)(N\times N) matrix of pairwise distances.

Value

a logical; TRUE if it satisfies metric property, FALSE otherwise.

See Also

checkdist

Examples

## 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)


[Package maotai version 0.2.5 Index]