public class MahalanobisDistance extends VectorNorm
VectorNorm.L1, VectorNorm.L2, VectorNorm.Linf, VectorNorm.NormType
Modifier and Type | Field and Description |
---|---|
static boolean |
BIAS_CORRECTION |
static double |
DEFAULT_DIAGONAL_INCREMENT |
Constructor and Description |
---|
MahalanobisDistance(double[][] samples)
Create a new instance from an array of m-dimensional samples, e.g.
|
MahalanobisDistance(double[][] samples,
double diagonalIncrement)
Create a new instance from an array of m-dimensional samples, e.g.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(double[] X)
Calculates the Mahalanobis distance between point X and
the mean of the reference distribution.
|
double |
distance(double[] X,
double[] Y)
Calculates the distance between two vectors.
|
double |
distance(float[] a,
float[] b) |
double |
distance(int[] a,
int[] b) |
double |
distance2(double[] X)
Calculates the sqared Mahalanobis distance between point X and
the mean of the reference distribution.
|
double |
distance2(double[] X,
double[] Y) |
double |
distance2(float[] a,
float[] b) |
double |
distance2(int[] a,
int[] b) |
double[][] |
getCovarianceMatrix() |
double[][] |
getInverseCovarianceMatrix() |
double[] |
getMeanVector() |
int |
getNumberOfSamples() |
int |
getSampleDimension() |
double |
getScale(int n)
Returns a factor to scale magnitude and distance values
to the range of the vector components of dimensionality
n.
|
double[][] |
getWhiteningTransformation()
Returns the 'root' (U) of the inverse covariance matrix S^{-1},
such that S^{-1} = U^T .
|
double |
magnitude(double[] X) |
double |
magnitude(int[] X) |
static void |
main(String[] args)
Test example from Burger/Burge UTICS-C Appendix:
N = 4 samples, K = 3 dimensions
|
public static final double DEFAULT_DIAGONAL_INCREMENT
public static final boolean BIAS_CORRECTION
public MahalanobisDistance(double[][] samples, double diagonalIncrement)
samples
- A vector of length n with m-dimensional samples, i.e.
samples[k][i] represents the i-th component of the k-th sample.diagonalIncrement
- Quantity added to the diagonal values of the
covariance matrix to avoid singularity.public MahalanobisDistance(double[][] samples)
samples
- A vector of length n with m-dimensional samples, i.e.
samples[k][i] represents the i-th component of the k-th sample.public int getNumberOfSamples()
public int getSampleDimension()
public double[][] getCovarianceMatrix()
public double[][] getInverseCovarianceMatrix()
public double[] getMeanVector()
public double[][] getWhiteningTransformation()
public double distance(double[] X, double[] Y)
VectorNorm
distance
in class VectorNorm
X
- first vectorY
- second vectorpublic double distance2(double[] X, double[] Y)
distance2
in class VectorNorm
X
- first vectorY
- second vectorpublic double distance(double[] X)
X
- an arbitrary K-dimensional vectorpublic double distance2(double[] X)
X
- an arbitrary K-dimensional vectorpublic double distance(int[] a, int[] b)
distance
in class VectorNorm
public double distance2(int[] a, int[] b)
distance2
in class VectorNorm
public double magnitude(double[] X)
magnitude
in class VectorNorm
public double magnitude(int[] X)
magnitude
in class VectorNorm
public double getScale(int n)
VectorNorm
getScale
in class VectorNorm
n
- dimensionalitypublic double distance(float[] a, float[] b)
distance
in class VectorNorm
public double distance2(float[] a, float[] b)
distance2
in class VectorNorm
Copyright © 2006–2017, Wilhelm Burger, Mark J. Burge (BSD 2-Clause Simplified License)