Class MahalanobisMetric
java.lang.Object
org.episteme.core.mathematics.topology.metrics.MahalanobisMetric
Mahalanobis distance metric.
The Mahalanobis distance is a measure of the distance between a point and a distribution. It accounts for correlations between variables and is scale-invariant.
For vectors x and y with covariance matrix S: d(x, y) = √((x-y)áµ€ S⻹ (x-y))
When S is the identity matrix, this reduces to Euclidean distance.
*
Reference:
Fréchet, M. (1906). Sur quelques points du calcul fonctionnel. Rendiconti del Circolo Matematico di Palermo.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
ConstructorsConstructorDescriptionMahalanobisMetric(DenseMatrix<Real> covariance) Creates a Mahalanobis metric with the given covariance matrix. -
Method Summary
Modifier and TypeMethodDescriptionComputes the distance between two objects.Returns the inverse covariance matrix.intReturns the dimension of this metric space.static MahalanobisMetricidentity(int dimension) Creates a Mahalanobis metric with identity covariance (equivalent to Euclidean).toString()
-
Constructor Details
-
MahalanobisMetric
Creates a Mahalanobis metric with the given covariance matrix.- Parameters:
covariance- the covariance matrix
-
-
Method Details
-
identity
Creates a Mahalanobis metric with identity covariance (equivalent to Euclidean).- Parameters:
dimension- the dimension- Returns:
- the metric
-
distance
Description copied from interface:MetricComputes the distance between two objects. -
getDimension
public int getDimension()Returns the dimension of this metric space.- Returns:
- the dimension
-
getCovarianceInverse
Returns the inverse covariance matrix.- Returns:
- the inverse covariance matrix
-
toString
-