geolime.utilities.distance¶
Data:
|
Callable type; Callable[[int], str] is a function of (int) -> str. |
Functions:
|
Anisotropic distance between two points according to the anisotropy matrix a. |
|
Computes the distance matrix of two sets of points in the Euclidean space according to a distance. |
|
Compute the Euclidean distance between two points. |
|
Computes pairwise distances |
|
Pairwise distances between observations in n-dimensional space. |
|
Convert a vector-form distance vector to a square-form distance matrix, and vice-versa. |
-
geolime.utilities.distance.
anisotropic_distance
(a: numpy.ndarray = array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))¶ Anisotropic distance between two points according to the anisotropy matrix a. This function DOES NOT compute a distance matrix. See distance_matrix function.
- Parameters
a (np.ndarray) – A must be an invertible square (numpy) matrix.
- Returns
This function returns a function f(X,Y) which computes de anistropic distance between X and Y.
- Return type
Callable
-
geolime.utilities.distance.
distance_matrix
(x1: numpy.ndarray, x2: numpy.ndarray, distance: Callable = <function euclidian_distance>)¶ Computes the distance matrix of two sets of points in the Euclidean space according to a distance.
- Parameters
x1 (np.ndarray) – A numpy matrix with the vectors to be analized in its rows.
x2 (np.ndarray) – A numpy matrix with the vectors to be analized in its rows (it must have the same number of columns as X1)
distance (Callable) – A distance function
- Returns
This functions returns a numpy matrix, where the (i,j)-th element corresponds to the distance between the i-th row of X1 and the j-th row of X2.
- Return type
np.ndarray
-
geolime.utilities.distance.
euclidian_distance
(x: numpy.ndarray, y: numpy.ndarray)¶ Compute the Euclidean distance between two points. x and y must be: - Two numpy arrays of same dimension - One numpy matrix and one numpy array, obtaining a numpy vector of distances between the rows of the matrix and the numpy vector (there must be a column compatibility) - Two numpy matrices of the same shape, obtaining a numpy vector with the distances between their rows.
- Parameters
x (np.ndarray) – First array for distance computation
y (np.ndarray) – Second array for distance computation
- Returns
Distance vector
- Return type
np.ndarray
-
geolime.utilities.distance.
pairwise
(coords: numpy.ndarray)¶ Computes pairwise distances
- Parameters
coords (np.ndarray) – array of cartesian coordinates (float)
- Returns
an N * N matrix with pairwise distances
- Return type
np.ndarray