distance — Some distance functions¶
This module provides distance helper functions.
-
diversipy.distance.distance_to_boundary(points, cuboid=None)¶ Calculate the distance of each point to the boundary of some cuboid.
This distance is simply the minimum of all differences between a point and the lower and upper bounds. This function also checks if all calculated distances are larger than zero. If not, some points must be located outside the cuboid.
Parameters: - points (array_like) – 2-D array of n points.
- cuboid (tuple of array_like, optional) – Contains the min and max bounds of the considered cuboid. If omitted, the unit hypercube is assumed.
Returns: distances – 1-D array of n distances
Return type: numpy array
-
diversipy.distance.distance_matrix(points1, points2, norm=2, max_dist=None)¶ Calculate the distance between each combination of points in two sets.
Parameters: - points1 (array_like) – 2-D array of n1 points.
- points2 (array_like) – 2-D array of n2 points.
- norm (int, optional) – Norm to use for the distance, by default 2 (euclidean norm).
- max_dist (array_like, optional) – 1-D array of largest possible distance in each dimension. Providing these values has the consequence of treating the cuboid as a torus. This is useful for eliminating edge effects induced by the lack of neighbor points outside the bounds of the cuboid.d
Returns: distances – (n1 x n2) array of distances
Return type: numpy array