R: Metric and triangle inequality

is_metric {rdist} | R Documentation

## Metric and triangle inequality

### Description

Does the distance matric come from a metric

### Usage

    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

    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)

[Package rdist version 0.0.5 Index]