Utilities#
- mellon.util.distance(x, y)#
Computes the distances between each point in x and y.
- Parameters:
x (array-like) – A set of points.
y (array-like) – A set of points.
- Returns:
distances - The distance between each point in x and y.
- Return type:
array-like
- mellon.util.mle(nn_distances, d)#
Nearest Neighbor distribution maximum likelihood estimate for log density given observed nearest neighbor distances \(nn\text{_}distances\) in dimensions \(d\): \(mle = \log(\text{gamma}(d/2 + 1)) - (d/2) \cdot \log(\pi) - d \cdot \log(nn\text{_}distances)\)
- Parameters:
nn_distances (array-like) – The observed nearest neighbor distances.
d (int) – The local dimensionality of the data.
- Returns:
\(mle\) - The maximum likelihood estimate at each point.
- Return type:
array-like
- mellon.util.stabilize(A, jitter=1e-06)#
Add a small jitter to the diagonal for numerical stability.
- Parameters:
A – A square matrix.
jitter (float) – The amount to add to the diagonal. Defaults to 1e-6.
- Returns:
\(A'\) - The matrix \(A\) with a small jitter added to the diagonal.
- Return type:
array-like