euclidean_dist#
- crispy.scms.euclidean_dist(X, G)[source]#
Compute the Euclidean distances and differences between data points and walkers.
This function calculates pairwise Euclidean distances between points in X and G and returns both the distances and the differences in their coordinates.
- Parameters:
X (ndarray) – Coordinates of the data points, shape (n, D, 1), where n is the number of points and D is the dimensionality.
G (ndarray) – Coordinates of the walkers, shape (m, D, 1), where m is the number of walkers.
- Returns:
distances (ndarray) – Pairwise Euclidean distances between each point in G and each point in X, shape (m, n).
diff (ndarray) – Pairwise coordinate differences between points in G and points in X, shape (m, n, D).
Notes
This function is useful for calculating distances and displacements required in SCMS-based ridge detection.
Examples
Compute pairwise distances and differences:
>>> import numpy as np >>> from crispy import scms >>> data = np.random.random((100, 3, 1)) # 3D data points >>> walkers = np.random.random((10, 3, 1)) # Walker positions >>> distances, diff = scms.euclidean_dist(data, walkers) >>> print(distances.shape) # Should be (10, 100) >>> print(diff.shape) # Should be (10, 100, 3)