Common distance calculation methods

1. Euclidean Distance

2. Manhattan Distance

You can't directly walk the straight line connecting two points, the distance between red, blue and yellow is the same

3. Chebyshev Distance

In chess, the king can move to any one of the 8 adjacent squares with one move, as shown in the figure below. The distance from A to B is the red line, and you need to walk 4 steps, which is the same distance as the green line.

4. Minkowski Distance

Min's distance is not a kind of distance, but a definition of a group of distances, which is a general expression of multiple distance measurement formulas.

The Minkowski distance between two n-dimensional variables a(x11,x12,...,x1n) and b(x21,x22,...,x2n) is defined as:

image-20190225182628694

where p is a variable parameter:

  • When p=1, it is the Manhattan distance;

  • When p=2, it is the Euclidean distance;

  • When p→∞, it is the Chebyshev distance, that is, when a certain value is infinite, the small value can be ignored.

According to the difference of p, Min's distance can represent the distance of a certain class/species.

Disadvantages of Min's distance:

​(  1) Treat the scale of each component, that is, the "unit" as the same;

​(  2) The distribution (expectation, variance, etc.) of each component is not considered may be different.

5. Standardized Euclidean Distance:

Improvement: Dequantization

Idea: Since the distribution of each dimensional component of the data is different, first "standardize" each component to equal mean and variance.

S​k​​Indicates the standard deviation of each dimension

image-20190213184012294

6. Cosine Distance

  • The cosine formula of the angle between vector A(x1,y1) and vector B(x2,y2) in two-dimensional space:cosine distance
  • The cosine of the angle between two n-dimensional sample points a(x11,x12,…,x1n) and b(x21,x22,…,x2n) is:cosine distance

Right now:

cosine distance

The value range of the cosine of the included angle is [-1,1]. The larger the cosine, the smaller the angle between the two vectors, and the smaller the cosine, the larger the angle between the two vectors. When the directions of the two vectors coincide, the cosine takes the maximum value of 1, and when the directions of the two vectors are completely opposite, the cosine takes the minimum value of -1.

 

 

 

 

 

Guess you like

Origin blog.csdn.net/lian740930980/article/details/114037815