Questions tagged [mahalanobis]

A dissimilarity metric to compute distance between a point and a distribution.

Learn more about the Mahalanobis distance on Wikipedia


Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of such metric.
Consider whether the question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

96 questions
1
vote
1 answer

Calculating weigthed pairwise Mahalanobis distances

I know that HDMD package has a function called pairwise.mahalanobis that is supposed to calculate the pairwise Mahalanobis Distance. However, I also want to introduce weights to this distance and it is not feasible with this function. Therefore, I…
1
vote
1 answer

Speeding up Mahalanobis distance calculation

Background: I am implementing a Sequential Backward Selection algorithm to select features from a dataset. The dataset in question is MNIST. I have 60000 vectors of length 784. The algorithm requires me to leave out one feature, fi from the total of…
1
vote
0 answers

Mahalanobis distance between two groups of observations

If this is a snapshot of my dataset. Row Group x y z Survive 1 1 0.0680 0.8701 0.0619 78.43507 2 1 0.9984 0.0016 0.0000 89.55533 3 1 0.4146 0.5787 0.0068 85.35468 4 2 0.3910 0.6016…
Science11
  • 788
  • 1
  • 8
  • 24
1
vote
0 answers

Error in types double and DenseVector[Double]

The following code is the answer to this question: Anomaly detection with PCA in Spark import breeze.linalg.{DenseVector, inv} import org.apache.spark.ml.Pipeline import org.apache.spark.ml.feature.{PCA, StandardScaler,VectorAssembler} import…
Yhprums
  • 189
  • 1
  • 11
1
vote
0 answers

Mahalanobis distance in sklearn DistanceMetrics got Singular matrix error

I'm trying to calculate Mahalanobis distance using following simple code: from sklearn.neighbors import DistanceMetric import numpy as np X = [[0, 1, 2], [3, 4, 5]] dist = DistanceMetric.get_metric('mahalanobis',…
user2334508
  • 303
  • 1
  • 3
  • 11
1
vote
2 answers

mahalanobis distance for pair of columns in data frame in R

I have a dataframe table and I would like to calculate the mahalanobis for each possible pair of column of my dataframe. A1 A2 A3 121.4984 219.5448 250.7575 121.5195 219.5451 250.7500 121.5089 …
1
vote
0 answers

Bootstrap for phylogenetic tree generated using Mahalanobis distance (R)

I created a phylogenetic NJ tree in R using the ape package. My data contains metric measures from multiple individuals belonging to known groups. Thus, I decided to calculate the Mahalanobis distance between these groups in order to incorporate the…
Anti
  • 365
  • 1
  • 14
1
vote
1 answer

The Mahalanobis distance between a point and the mean vector is always the same

I‘m trying to perform some data cleansing algorithm recently. When I try to calculate the mahalanobis distance between points in the data set and the mean vector, it seems the same. For example, I have a data set like: {{2,2,3},{4,5,9},{7,8,9}} The…
simon s
  • 135
  • 1
  • 4
  • 15
1
vote
0 answers

Having issues with finding the centroid and covariance matrix used in the mvoutlier function

I am trying to find the centroid and covariance matrix used by mvoutlier to calculate its Mahalanobis distance. When I try to calculate the Mahalanobis distance myself it does not line up with the results from mvoutlier. The Mahalanobis distances…
1
vote
0 answers

Hotelling's T^2 test example using Mahalanobis distance to determine difference between groups

I'm am trying to follow the procedure described in this publication to determine whether separation between groups is statistically significant. The level of that publication is above my knowledge skyline, but I'm trying to approach it step by step.…
raumkundschafter
  • 429
  • 1
  • 8
  • 24
1
vote
1 answer

Simple example calculating Mahalanobis distance between two groups in R

I'm trying to reproduce this example using Excel to calculate the Mahalanobis distance between two groups. To my mind the example provides a good explanation of the concept. However, I'm not able to reproduce in R. The result obtained in the…
raumkundschafter
  • 429
  • 1
  • 8
  • 24
1
vote
1 answer

Drawing Curves of Mahalanobis Distance while Specifying a Feature Vector in Bayes Decision Theory in R

I'm studying pattern recognition and statistics.I like to use direct functions in R rather than explicitly writing codes. My question is that in a three class 2-dimensional problem, my feature vectors for each class are normally distributed with…
1
vote
1 answer

Vectorizing (squared) mahalanobis distance in numpy

I have X (n x d), Y (m x d), and positive-definite L (d x d). I want to calculate D where D_ij is (X_i - Y_i) * L * (X_i - Y_i).T. n and m are around 250; d is around 10^4. I can use scipy.spatial.distance.cdist, but this is very slow.…
Kevin Yang
  • 167
  • 7
1
vote
1 answer

Mahalanobis Distance with a three variables vector

I'm having some trouble in calculating the Mahalanobis Distance between a pair of objects. I followed the documentation of MATLAB where in order to calculate Mahalanobis Distance, I have to use pdist2: "D = pdist2(X,Y,'mahalanobis',C)" A1=[75 87…
FL93
  • 29
  • 5