Mahalanobis Distance(馬氏距離)


(from:http://en.wikipedia.org/wiki/Mahalanobis_distance)

 

Mahalanobis distance

In statisticsMahalanobis distance is a distance measure introduced by P. C. Mahalanobis in 1936.It is based on correlations between variables by which different patterns can be identified and analyzed. It gauges similarity of an unknown sample set to a known one. It differs fromEuclidean distance in that it takes into account the correlations of the data set and is scale-invariant. In other words, it is a multivariateeffect size.

Definition

Formally, the Mahalanobis distance of a multivariate vector x = ( x_1, x_2, x_3, \dots, x_N )^T from a group of values with mean \mu = ( \mu_1, \mu_2, \mu_3, \dots , \mu_N )^T and covariance matrix S is defined as:

D_M(x) = \sqrt{(x - \mu)^T S^{-1} (x-\mu)}.\,

(注:1.這個是X和總體均值的馬氏距離。2.這里的S是可逆的,那么協方差矩陣不可逆的話怎么辦?)

Mahalanobis distance (or "generalized squared interpoint distance" for its squared value) can also be defined as a dissimilarity measure between two random vectors  \vec{x} and  \vec{y} of the same distribution with the covariance matrix S :

 d(\vec{x},\vec{y})=\sqrt{(\vec{x}-\vec{y})^T S^{-1} (\vec{x}-\vec{y})}.\,

If the covariance matrix is the identity matrix, the Mahalanobis distance reduces to the Euclidean distance. If the covariance matrix is diagonal, then the resulting distance measure is called the normalized Euclidean distance:

 d(\vec{x},\vec{y})=
\sqrt{\sum_{i=1}^N  {(x_i - y_i)^2 \over s_{i}^2}},

where s_{i} is the standard deviation of the  x_i  (  y_i ) over the sample set.

(源自:百度百科)

馬氏優缺點:

1.馬氏距離的計算是建立在總體樣本的基礎上的,這一點可以從上述協方差矩陣的解釋中可以得出,也就是說,如果拿同樣的兩個樣本,放入兩個不同的總體中,最后計算得出的兩個樣本間的馬氏距離通常是不相同的,除非這兩個總體的協方差矩陣碰巧相同。
 
2.在計算馬氏距離過程中,要求總體樣本數大於樣本的維數,否則得到的總體樣本協方差矩陣逆矩陣不存在,這種情況下,用歐式距離計算即可。
 
3.還有一種情況,滿足了條件總體樣本數大於樣本的維數,但是協方差矩陣的逆矩陣仍然不存在,比如三個樣本點(3,4),(5,6)和(7,8)這種情況是因為這三個樣本在其所處的二維空間平面內共線。這種情況下,也采用歐式距離計算。
 
4.在實際應用中“總體樣本數大於樣本的維數”這個條件是很容易滿足的,而所有樣本點出現3)中所描述的情況是很少出現的,所以在絕大多數情況下,馬氏距離是可以順利計算的,但是馬氏距離的計算是不穩定的,不穩定的來源是協方差矩陣,這也是馬氏距離與歐式距離的最大差異之處。
   
優點:它不受量綱的影響,兩點之間的馬氏距離與原始數據的測量單位無關;由標准化數據和中心化數據(即原始數據與均值之差)計算出的二點之間的馬氏距離相同。馬氏距離還可以排除變量之間的相關性的干擾。
 
缺點:它的缺點是誇大了變化微小的變量的作用。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM