Learn R Programming

fossil (version 0.4.0)

tri.ineq: Testing for the Triangle Inequality

Description

Determines if a distance matrix obeys the triangle inequality

Usage

tri.ineq(dist)

Arguments

dist

A distance matrix

Value

Returns a TRUE if the inequality is respected, and a FALSE if there is any situation where the triangle inequality is not respected.

Details

Tests if a distance matrix respects the triangle inequality. Often with non-monotonic distance measures and complex data a situation can arise where the triangle inequality (where no single side of a triangle is greater in length than the sum of the other two sides) is not respected.

See Also

ecol.dist

Examples

Run this code
# NOT RUN {
## sample distance matrix with an impossible triangle
a<-matrix(0.2, 4,4)
a[4,2]<-0.8
a<-as.dist(a)
tri.ineq(a)
# }

Run the code above in your browser using DataLab