is_metric: Metric and triangle inequality

Description Usage Arguments Examples

Description

Does the distance matric come from a metric

Usage

1
2
3
is_distance_matrix(mat, tolerance = .Machine$double.eps^0.5)

triangle_inequality(mat, tolerance = .Machine$double.eps^0.5)

Arguments

mat

The matrix to evaluate

tolerance

Differences smaller than tolerance are not reported.

Examples

1
2
3
4
5
6
7
data <- matrix(rnorm(20), ncol = 2)
dm <- pdist(data)
is_distance_matrix(dm)
triangle_inequality(dm)

dm[1, 2] <- 1.1 * dm[1, 2]
is_distance_matrix(dm)

rdist documentation built on May 4, 2020, 5:13 p.m.