Distance
Catalog of distance functions.
dist
means distance
wdist
means weighted distance
All distance functions are defined for comparison between 2 1D vectors.
AbstractDist
Bases: Module
Ensures that all distance functions have the same signatures.
Source code in src/somap/distance.py
__call__(a, b)
abstractmethod
SOM distance function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
Float[Array, ' n']
|
1D array. |
required |
b |
Float[Array, ' n']
|
1D array. |
required |
Returns:
Type | Description |
---|---|
Float[Array, '']
|
The distance as a scalar. |
CyclicEuclidianDist
Bases: AbstractDist
Cyclic euclidian distance function.
Source code in src/somap/distance.py
__call__(a, b)
Returns a cyclic euclidian distance where 0 and 1 are equals.
More optimized than the arccos(cos())
based cyclic distance.
Takes advantage of data type's limits.
Source code in src/somap/distance.py
EuclidianDist
dist_cim(v1, v2, sigma)
The Correntropy Induced Metric (CIM) distance.
It is based on correntropy which is a generalized correlation. It computes the distance between two vectors without suffering from the curse of dimensionality like the Euclidian distance thanks to a kernel function. The chosen kernel is a Gaussian function (parameterised by 'sigma'). For large sigma, the CIM distance tends to the L2 metric. For very small sigma, the CIM distance tends to the L0 norm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v1 |
first vector to be compared |
required | |
v2 |
second vector to be compared |
required | |
sigma |
kernel bandwidth |
required |
Returns:
Type | Description |
---|---|
A scalar value between 0 and 1 corresponding to the similarity between v1 and v2 |
Raises:
Type | Description |
---|---|
ValueError
|
incompatible shapes of v1 and v2 |
Source code in src/somap/distance.py
wdist_l2(a, b, w)
Computes a weighted version of the euclidian norm.