Skip to content

Algorithms

Distance measures for data science: Manhattan, Euclidean and Minkowski.

1 min read

Distance Measures

Distance Measures

Manhattan Distance

Manhattan distance calculates the distance between two real-valued vectors.

DManhattan(x,y)=∑i=1n∣xi−yi∣D_{Manhattan}(x,y) = \sum_{i=1}^{n} |x_i - y_i|

Euclidean Distance

Euclidean distance calculates the distance between two real-valued vectors.

DEuclidean(x,y)=∑i=1n∣xi−yi∣2D_{Euclidean}(x,y) = \sqrt{\sum_{i=1}^{n} |x_i - y_i|^2}

Minkowski Distance

Minkowski distance calculates the distance between two real-valued vectors.

It is a generalization of the Euclidean and Manhattan distance measures and adds a parameter, called the “order” or “p“, that allows different distance measures to be calculated.

  • pp is an integer
  • x=(x1,x2,...,xn)]∈Rnx=(x_1,x_2,...,x_n) ]\in \mathbb{R}^n is a real-valued vector
  • y=(y1,y2,...,yn)]∈Rny=(y_1,y_2,...,y_n) ]\in \mathbb{R}^n is a real-valued vector

DMinkowski(x,y)=(∑i=1n∣xi−yi∣p)1/pD_{Minkowski}(x,y) = \Big( \sum_{i=1}^{n} | x_i - y_i | ^p \Big) ^{1/p}

  • p=1⇒p=1 \Rightarrow Manhattan distance
  • p=2⇒p=2 \Rightarrow Euclidean distance
  • p=∞⇒p=\infty \Rightarrow Chebyshev distance

Related articles

1 min readTürkçe

ollama

CPU'lu makinelerde Ollama ile yerel LLM çalıştırma ve performansı artıran kritik ayarlar.

  • AI & Data
  • DevOps & Containers
2 min read

Hadoop

Installing and configuring Hadoop on a single machine: core-site, hdfs-site, mapred-site and SSH setup.

  • AI & Data
5 min read

Algorithms for machine learning

An overview of supervised learning algorithms — regression, classification and the math behind how models learn.

  • AI & Data

Type to search the whole site.