repair_distance_matrix: Repair distance matrix

View source: R/repairDM.R

repair_distance_matrixR Documentation

Repair distance matrix

Description

This function can repair distance matrix to satisfy all conditions needed for proper input for algorithms which are looking for points positions.

Usage

repair_distance_matrix(m, max.iter = 5)

Arguments

m

original distance matrix

max.iter

= 5, repairing third metric rule can be a little bit tricky when there are many triples combination which don't fulfill it. In such situation many iterations are needed. If number of needed iteration exceeds max.iter, simple matrix will be returned when all possible distances between points will be equal to the mean distance in original matrix.

Details

  • If matrix is not square, it will be extended to fulfill this condition

  • All NA will be replaced by real values

  • All negative values will be changed by abs function

  • First metric rule will be forced (d(x,y) = 0 <=> x = y)

  • Second metric rule will be forced (d(x,y) = d(y,x))

  • Third metric rule will be forced (d(x,z) <= d(x,y) + d(y,z))

All changes are performed in intelligent way to change original matrix as less as possible

Value

repaired distance matrix (or original if repairing is not needed)


maszdev/dist2location documentation built on June 11, 2025, 11:55 a.m.