scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
directed_hausdorff(u, v, seed=0)

Distances between pairs are calculated using a Euclidean metric.

Notes

Uses the early break technique and the random sampling approach described by . Although worst-case performance is O(m * o) (as with the brute force algorithm), this is unlikely in practice as the input data would have to require the algorithm to explore every single point interaction, and after the algorithm shuffles the input points at that. The best case performance is O(m), which is satisfied by selecting an inner loop distance that is less than cmax and leads to an early break as often as possible. The authors have formally shown that the average runtime is closer to O(m).

versionadded

Parameters

u : (M,N) array_like

Input array.

v : (O,N) array_like

Input array.

seed : int or None

Local numpy.random.RandomState seed. Default is 0, a random shuffling of u and v that guarantees reproducibility.

Raises

ValueError

An exception is thrown if u and v do not have the same number of columns.

Returns

d : double

The directed Hausdorff distance between arrays u and v,

index_1 : int

index of point contributing to Hausdorff pair in u

index_2 : int

index of point contributing to Hausdorff pair in v

Compute the directed Hausdorff distance between two 2-D arrays.

See Also

scipy.spatial.procrustes

Another similarity test for two data sets

Examples

Find the directed Hausdorff distance between two 2-D arrays of coordinates:

>>> from scipy.spatial.distance import directed_hausdorff
... u = np.array([(1.0, 0.0),
...  (0.0, 1.0),
...  (-1.0, 0.0),
...  (0.0, -1.0)])
... v = np.array([(2.0, 0.0),
...  (0.0, 2.0),
...  (-2.0, 0.0),
...  (0.0, -4.0)])
>>> directed_hausdorff(u, v)[0]
2.23606797749979
>>> directed_hausdorff(v, u)[0]
3.0

Find the general (symmetric) Hausdorff distance between two 2-D arrays of coordinates:

>>> max(directed_hausdorff(u, v)[0], directed_hausdorff(v, u)[0])
3.0

Find the indices of the points that generate the Hausdorff distance (the Hausdorff pair):

>>> directed_hausdorff(v, u)[1:]
(3, 3)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.spatial.distance.directed_hausdorff scipy.spatial._procrustes.procrustes

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/spatial/distance.py#321
type: <class 'function'>
Commit: