# Euclidean Distance

Euclidean Distance

The Euclidean Distance is a Distance Metric used in machine learning. This distance is used to compare how similar two vectors of uniform length are. A lower length indicates that the two vectors are more similar than two vectors with a larger length.

## Mathematical Basis

The Euclidean distance is based off of real two-dimensional distance. That is, if you drew two points on a paper, and measured with a ruler. This two dimensional distance is based on the pythagorean theorem. Specifically, if you had two points (x1,y1) and (x2,y2) this distence would be given as follows.

$d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}.\,$

This would work fine for comparing two vectors of length two. However, most vectors are longer than two numbers. To calculate the Euclidean distance for any sized vector, use the general form of the Euclidean distance equation.

$\mathrm{d}(\mathbf{p},\mathbf{q}) = \sqrt{(q_1-p_1)^2 + (q_2-p_2)^2 + \cdots + (q_n-p_n)^2} = \sqrt{\sum_{i=1}^n (q_i-p_i)^2}.$