Skip to content

calibrax.metrics.functional.geometric¤

Geometric and point cloud metrics for comparing unordered point sets. Includes Chamfer distance, directed and symmetric Hausdorff distance, and 1D Earth Mover's Distance (Wasserstein-1).

Geometric and point cloud metrics -- pure math.

Distance metrics for comparing point sets and shapes. All operations are pure mathematical -- no pretrained models or external libraries.

Includes: chamfer_distance, earth_movers_distance_1d, directed_hausdorff, hausdorff_distance. Registered with domain="geometric".

chamfer_distance(set_a: Any, set_b: Any) -> Any ¤

Chamfer distance between two point sets.

Mean of nearest-neighbor distances in both directions. Symmetric: CD(A, B) = CD(B, A).

Parameters:

Name Type Description Default
set_a Any

First point set, shape (n, d).

required
set_b Any

Second point set, shape (m, d).

required

Returns:

Type Description
Any

Chamfer distance. Lower is better. 0.0 = identical sets.

Examples:

>>> import jax.numpy as jnp
>>> pts = jnp.array([[0.0, 0.0], [1.0, 1.0]])
>>> chamfer_distance(pts, pts)
0.0

earth_movers_distance_1d(a: Any, b: Any) -> Any ¤

1D Earth Mover's Distance (Wasserstein-1).

Delegates to wasserstein_1d from the divergence module (DRY).

Parameters:

Name Type Description Default
a Any

First 1D distribution/sample array.

required
b Any

Second 1D distribution/sample array.

required

Returns:

Type Description
Any

EMD value. Lower is better. 0.0 = identical distributions.

Examples:

>>> import jax.numpy as jnp
>>> earth_movers_distance_1d(jnp.array([1.0, 2.0, 3.0]), jnp.array([1.0, 2.0, 3.0]))
0.0

directed_hausdorff(set_a: Any, set_b: Any) -> Any ¤

Directed Hausdorff distance from set_a to set_b.

max_{a in A} min_{b in B} d(a, b). NOT symmetric: directed_hausdorff(A, B) != directed_hausdorff(B, A) in general.

Measures the worst-case nearest-neighbor distance from A to B.

Parameters:

Name Type Description Default
set_a Any

Source point set, shape (n, d).

required
set_b Any

Target point set, shape (m, d).

required

Returns:

Type Description
Any

Directed Hausdorff distance. Lower is better.

Examples:

>>> import jax.numpy as jnp
>>> a = jnp.array([[0.0, 0.0], [1.0, 0.0]])
>>> b = jnp.array([[0.0, 0.0]])
>>> directed_hausdorff(a, b)  # 1.0 (point [1,0] is 1.0 from [0,0])
...

hausdorff_distance(set_a: Any, set_b: Any) -> Any ¤

Hausdorff distance (symmetric) between two point sets.

max(directed_hausdorff(A, B), directed_hausdorff(B, A)). A true metric on non-empty compact subsets.

Parameters:

Name Type Description Default
set_a Any

First point set, shape (n, d).

required
set_b Any

Second point set, shape (m, d).

required

Returns:

Type Description
Any

Hausdorff distance. Lower is better. 0.0 = identical sets.

Examples:

>>> import jax.numpy as jnp
>>> pts = jnp.array([[0.0, 0.0], [1.0, 1.0]])
>>> hausdorff_distance(pts, pts)
0.0