Difference between revisions of "Distance Functions, Metrics"

From Department of Mathematics at UTSA
Jump to navigation Jump to search
(Created page with "thumb|200px|An illustration comparing the [[Taxicab geometry|taxicab metric to the Euclidean metric on the plane: According to the taxicab metr...")
 
 
Line 1: Line 1:
[[File:Manhattan distance.svg|thumb|200px|An illustration comparing the [[Taxicab geometry|taxicab metric]] to the Euclidean metric on the plane: According to the taxicab metric the red, yellow, and blue paths have the same [[Arc length|length]] (12). According to the Euclidean metric, the green path has length <math>6 \sqrt{2} \approx 8.49</math>, and is the unique shortest path.]]
+
[[File:Manhattan distance.svg|thumb|200px|An illustration comparing the taxicab metric to the Euclidean metric on the plane: According to the taxicab metric the red, yellow, and blue paths have the same length (12). According to the Euclidean metric, the green path has length <math>6 \sqrt{2} \approx 8.49</math>, and is the unique shortest path.]]
  
In [[mathematics]], a '''metric''' or '''distance function''' is a [[function (mathematics)|function]] that gives a [[distance]]  between each pair of point elements of a [[Set (mathematics)|set]]. A set with a metric is called a [[metric space]].{{sfn|Čech|1969}} A metric induces a [[topology]] on a set, but not all topologies can be generated by a metric. A [[topological space]] whose topology can be described by a metric is called [[metrizable]].
+
In mathematics, a '''metric''' or '''distance function''' is a function that gives a distance between each pair of point elements of a set. A set with a metric is called a metric space. A metric induces a topology on a set, but not all topologies can be generated by a metric. A topological space whose topology can be described by a metric is called metrizable.
  
One important source of metrics in [[differential geometry]] are [[metric tensor]]s, [[bilinear form]]s that may be defined from the [[tangent vector]]s of a [[differentiable manifold]] onto a scalar. A metric tensor allows distances along curves to be determined through integration, and thus determines a metric.
+
One important source of metrics in differential geometry are metric tensors, bilinear forms that may be defined from the tangent vectors of a differentiable manifold onto a scalar. A metric tensor allows distances along curves to be determined through integration, and thus determines a metric.
  
 
==Definition==
 
==Definition==
  
A metric on a set {{mvar|X}} is a [[function (mathematics)|function]] (called ''distance function'' or simply ''distance'')
+
A metric on a set {{mvar|X}} is a function (called ''distance function'' or simply ''distance'')
 
:<math>d : X \times X \to [0,\infty),</math>
 
:<math>d : X \times X \to [0,\infty),</math>
where <math>[0,\infty)</math> is the set of non-negative [[real number]]s and for all <math>x, y, z \in X</math>, the following three axioms are satisfied:
+
where <math>[0,\infty)</math> is the set of non-negative real numbers and for all <math>x, y, z \in X</math>, the following three axioms are satisfied:
  
 
:{|
 
:{|
 
|-
 
|-
 
|style="width:2"| 1.  
 
|style="width:2"| 1.  
|style="width:250px"|<math>d(x, y) = 0 \Leftrightarrow x = y</math> || [[identity of indiscernibles]]
+
|style="width:250px"|<math>d(x, y) = 0 \Leftrightarrow x = y</math> || identity of indiscernibles
 
|-
 
|-
| 2. || <math>d(x, y)  = d(y, x) </math> || [[Symmetric function|symmetry]]
+
| 2. || <math>d(x, y)  = d(y, x) </math> || symmetry
 
|-
 
|-
| 3. || <math>d(x, y) \le d(x, z) + d(z, y)</math>  || [[triangle inequality]]
+
| 3. || <math>d(x, y) \le d(x, z) + d(z, y)</math>  || triangle inequality
 
|}
 
|}
  
Line 27: Line 27:
 
<math>0 = d(x, x) \le d(x, y) + d(y, x) = d(x, y) + d(x, y) = 2 d(x, y)</math> which implies <math>0 \le d(x, y)</math>.
 
<math>0 = d(x, x) \le d(x, y) + d(y, x) = d(x, y) + d(x, y) = 2 d(x, y)</math> which implies <math>0 \le d(x, y)</math>.
  
A metric is called an [[ultrametric space|ultrametric]] if it satisfies the following stronger version of the ''triangle inequality'' where points can never fall 'between' other points:
+
A metric is called an ultrametric if it satisfies the following stronger version of the ''triangle inequality'' where points can never fall 'between' other points:
 
: <math>d(x, y) \leq \max(d(x, z), d(y, z))</math>
 
: <math>d(x, y) \leq \max(d(x, z), d(y, z))</math>
 
for all <math>x, y, z \in X</math>
 
for all <math>x, y, z \in X</math>
  
A metric {{mvar|d}} on {{mvar|X}} is called [[Intrinsic metric|intrinsic]] if any two points {{mvar|x}} and {{mvar|y}} in {{mvar|X}} can be joined by a [[curve]] with [[Curve#Lengths of curves|length]] arbitrarily close to {{math|''d''(''x'', ''y'')}}.
+
A metric {{mvar|d}} on {{mvar|X}} is called intrinsic if any two points {{mvar|x}} and {{mvar|y}} in {{mvar|X}} can be joined by a curve with length arbitrarily close to {{math|''d''(''x'', ''y'')}}.
  
A metric ''d'' on a group ''G'' (written multiplicatively) is said to be {{em|left-invariant}} (resp. {{em|right invariant}}) if we have
+
A metric ''d'' on a group ''G'' (written multiplicatively) is said to be ''left-invariant'' (resp. ''right invariant'') if we have
 
:<math>d(zx, zy) = d(x, y)</math> [resp. <math>d(xz,yz)=d(x,y)</math>]
 
:<math>d(zx, zy) = d(x, y)</math> [resp. <math>d(xz,yz)=d(x,y)</math>]
 
for all ''x'', ''y'', and ''z'' in ''G''.
 
for all ''x'', ''y'', and ''z'' in ''G''.
  
A metric <math>D</math> on a commutative additive group <math>X</math> is said to be {{em|translation invariant}} if <math>D(x, y) = D(x + z, y + z)</math> for all <math>x, y, z \in X,</math> or equivalently, if <math>D(x, y) = D(x - y, 0)</math> for all <math>x, y \in X.</math> Every [[vector space]] is also a commutative additive group and a metric on a real or complex vector space that is induced by a [[Norm (mathematics)|norm]] is always translation invariant. A metric <math>D</math> on a real or complex vector space <math>X</math> is induced by a norm if and only if it is translation invariant and {{em|absolutely homogeneous}}, where the latter means that <math>D(sx, sy) = |s| D(x, y)</math> for all scalars <math>s</math> and all <math>x, y \in X,</math> in which case the function <math>\| x \| := D(x, 0)</math> defines a norm on <math>X</math> and the canonical metric induced by <math>\| \cdot \|</math> is equal to <math>D.</math>
+
A metric <math>D</math> on a commutative additive group <math>X</math> is said to be ''translation invariant'' if <math>D(x, y) = D(x + z, y + z)</math> for all <math>x, y, z \in X,</math> or equivalently, if <math>D(x, y) = D(x - y, 0)</math> for all <math>x, y \in X.</math> Every vector space is also a commutative additive group and a metric on a real or complex vector space that is induced by a norm is always translation invariant. A metric <math>D</math> on a real or complex vector space <math>X</math> is induced by a norm if and only if it is translation invariant and ''absolutely homogeneous'', where the latter means that <math>D(sx, sy) = |s| D(x, y)</math> for all scalars <math>s</math> and all <math>x, y \in X,</math> in which case the function <math>\| x \| := D(x, 0)</math> defines a norm on <math>X</math> and the canonical metric induced by <math>\| \cdot \|</math> is equal to <math>D.</math>
  
 
== Notes ==
 
== Notes ==
  
These conditions express intuitive notions about the concept of [[distance]]. For example, that the distance between distinct points is positive and the distance from ''x'' to ''y'' is the same as the distance from ''y'' to ''x''. The triangle inequality means that the distance from ''x'' to ''z'' via ''y'' is at least as great as from ''x'' to ''z'' directly. [[Euclid]] in his [[Euclidean geometry|work]] stated that the shortest distance between two points is a line; that was the triangle inequality for his geometry.
+
These conditions express intuitive notions about the concept of distance. For example, that the distance between distinct points is positive and the distance from ''x'' to ''y'' is the same as the distance from ''y'' to ''x''. The triangle inequality means that the distance from ''x'' to ''z'' via ''y'' is at least as great as from ''x'' to ''z'' directly. Euclid in his work stated that the shortest distance between two points is a line; that was the triangle inequality for his geometry.
  
 
== Examples ==
 
== Examples ==
 
+
* The discrete metric: if ''x'' = ''y'' then ''d''(''x'',''y'') = 0.  Otherwise, ''d''(''x'',''y'') = 1.
{{Main|Metric space#Examples of metric spaces}}
+
* The Euclidean metric is translation and rotation invariant.
* The [[discrete space|discrete metric]]: if ''x'' = ''y'' then ''d''(''x'',''y'') = 0.  Otherwise, ''d''(''x'',''y'') = 1.
+
* The taxicab metric is translation invariant.
* The [[Euclidean metric]] is translation and rotation invariant.
+
* More generally, any metric induced by a norm is translation invariant.
* The [[Taxicab geometry|taxicab metric]] is translation invariant.
+
* If <math>(p_n)_{n\in \N}</math> is a sequence of seminorms defining a (locally convex) topological vector space ''E'', then <math display="block">d(x,y)=\sum_{n=1}^\infty \frac{1}{2^n} \frac{p_n(x-y)}{1+p_n(x-y)}</math> is a metric defining the same topology. (One can replace <math display="inline"> \frac{1}{2^n}</math> by any summable sequence <math>(a_n)</math> of strictly positive numbers.)
* More generally, any metric induced by a [[norm (mathematics)|norm]] is translation invariant.
+
* The normed space <math>(\R, | \cdot |)</math> is a Banach space where the absolute value is a norm on the real line <math>\R</math> that induces the usual Euclidean topology on <math>\R.</math> Define a metric <math>D : \R \times \R \to \R</math> on <math>\R</math> by <math>D(x, y) = | \arctan(x) - \arctan(y)|</math> for all <math>x, y \in \R.</math> Just like <math>| \cdot |</math>'s induced metric, the metric <math>D</math> also induces the usual Euclidean topology on {{math|'''R'''}}. However, <math>D</math> is not a complete metric because the sequence <math>x_{\bull} = \left(x_i\right)_{i=1}^{\infty}</math> defined by <math>x_i := i</math> is a <math>D</math>-Cauchy sequence but it does not converge to any point of {{math|'''R'''}}. As a consequence of not converging, this <math>D</math>-Cauchy sequence cannot be a Cauchy sequence in <math>(\R, | \cdot |)</math> (i.e. it is not a Cauchy sequence with respect to the norm <math>\| \cdot \|</math>) because if it was <math>| \cdot |</math>-Cauchy, then the fact that <math>(\R, | \cdot |)</math> is a Banach space would imply that it converges (a contradiction).
* If <math>(p_n)_{n\in \N}</math> is a [[sequence]] of [[seminorm]]s defining a ([[locally convex]]) [[topological vector space]] ''E'', then <math display="block">d(x,y)=\sum_{n=1}^\infty \frac{1}{2^n} \frac{p_n(x-y)}{1+p_n(x-y)}</math> is a metric defining the same [[topology]]. (One can replace <math display="inline"> \frac{1}{2^n}</math> by any [[absolute convergence|summable sequence]] <math>(a_n)</math> of strictly [[positive number]]s.)
+
* Graph metric, a metric defined in terms of distances in a certain graph.
* The [[normed space]] <math>(\R, | \cdot |)</math> is a [[Banach space]] where the absolute value is a [[Norm (mathematics)|norm]] on the real line <math>\R</math> that induces the usual [[Euclidean topology]] on <math>\R.</math> Define a metric <math>D : \R \times \R \to \R</math> on <math>\R</math> by <math>D(x, y) = | \arctan(x) - \arctan(y)|</math> for all <math>x, y \in \R.</math> Just like {{nowrap|<math>| \cdot |</math>{{hsp}}'s}} induced metric, the metric <math>D</math> also induces the usual Euclidean topology on {{math|'''R'''}}. However, <math>D</math> is not a complete metric because the sequence <math>x_{\bull} = \left(x_i\right)_{i=1}^{\infty}</math> defined by <math>x_i := i</math> is a [[Cauchy sequence|{{nowrap|<math>D</math>-Cauchy}} sequence]] but it does not converge to any point of {{math|'''R'''}}. As a consequence of not converging, this {{nowrap|<math>D</math>-Cauchy}} sequence cannot be a Cauchy sequence in <math>(\R, | \cdot |)</math> (i.e. it is not a Cauchy sequence with respect to the norm <math>\| \cdot \|</math>) because if it was {{nowrap|<math>| \cdot |</math>-Cauchy,}} then the fact that <math>(\R, | \cdot |)</math> is a Banach space would imply that it converges (a contradiction).{{sfn|Narici|Beckenstein|2011|pp=47–51}}
+
* The Hamming distance in coding theory.
* [[Graph metric]], a metric defined in terms of distances in a certain graph.
+
* Riemannian metric, a type of metric function that is appropriate to impose on any differentiable manifold. For any such manifold, one chooses at each point ''p'' a symmetric, positive definite, bilinear form ''L'': T<sub>''p''</sub> × T<sub>''p''</sub> → '''R''' on the tangent space T<sub>''p''</sub> at ''p'', doing so in a smooth manner. This form determines the length of any tangent vector '''v''' on the manifold, via the definition <math display="inline">\|v\| = \sqrt{L(\mathbf{v}, \mathbf{v})}</math>. Then for any differentiable path on the manifold, its length is defined as the integral of the length of the tangent vector to the path at any point, where the integration is done with respect to the path parameter.  Finally, to get a metric defined on any pair {''x'', ''y''} of points of the manifold, one takes the infimum, over all paths from ''x'' to ''y'', of the set of path lengths. A smooth manifold equipped with a Riemannian metric is called a Riemannian manifold.
* The [[Hamming distance]] in coding theory.
+
* The Fubini–Study metric on complex projective space. This is an example of a Riemannian metric.
* [[Riemannian metric]], a type of metric function that is appropriate to impose on any [[differentiable manifold]]. For any such [[manifold]], one chooses at each point ''p'' a symmetric, positive definite, bilinear form ''L'': T<sub>''p''</sub> × T<sub>''p''</sub> → '''R''' on the [[tangent space]] T<sub>''p''</sub> at ''p'', doing so in a smooth manner. This form determines the length of any tangent vector '''v''' on the manifold, via the definition <math display="inline">\|v\| = \sqrt{L(\mathbf{v}, \mathbf{v})}</math>. Then for any differentiable path on the manifold, its length is defined as the integral of the length of the tangent vector to the path at any point, where the integration is done with respect to the path parameter.  Finally, to get a metric defined on any pair {''x'', ''y''} of points of the manifold, one takes the infimum, over all paths from ''x'' to ''y'', of the set of path lengths. A smooth manifold equipped with a Riemannian metric is called a [[Riemannian manifold]].
+
* String metrics, such as Levenshtein distance and other string edit distances, define a metric over strings.
* The [[Fubini–Study metric]] on [[complex projective space]]. This is an example of a Riemannian metric.
+
* Graph edit distance defines a distance function between graphs.
* [[String metric]]s, such as [[Levenshtein distance]] and other [[Edit distance|string edit distances]], define a metric over [[String (computer science)|strings]].
+
* The Wasserstein metric is a distance function defined between two probability distributions.
* [[Graph edit distance]] defines a distance function between [[Graph (discrete mathematics)|graphs]].
+
* The Finsler metric is a continuous nonnegative function F: TM → [0,+∞) defined on the tangent bundle.
* The [[Wasserstein metric]] is a distance function defined between two [[probability distribution]]s.
 
* The [[Finsler metric]] is a continuous nonnegative function {{nowrap|F: TM → [0,+∞)}} defined on the tangent bundle.
 
  
 
== Equivalence of metrics ==
 
== Equivalence of metrics ==
  
 
For a given set ''X'', two metrics ''d''<sub>1</sub> and ''d''<sub>2</sub> are called ''topologically equivalent'' (''uniformly equivalent'') if the identity mapping
 
For a given set ''X'', two metrics ''d''<sub>1</sub> and ''d''<sub>2</sub> are called ''topologically equivalent'' (''uniformly equivalent'') if the identity mapping
{{block indent|em=1.2|id: (''X'',''d''<sub>1</sub>) → (''X'',''d''<sub>2</sub>)}}
+
:''id: (''X'',''d''<sub>1</sub>) → (''X'',''d''<sub>2</sub>)''
is a [[homeomorphism]] ([[uniform isomorphism]]).
+
 
 +
is a homeomorphism (uniform isomorphism).
  
 
For example, if <math>d</math> is a metric, then <math>\min (d, 1)</math> and <math>\frac{d}{1+d}</math> are metrics equivalent to <math>d.</math>
 
For example, if <math>d</math> is a metric, then <math>\min (d, 1)</math> and <math>\frac{d}{1+d}</math> are metrics equivalent to <math>d.</math>
  
{{See also|Metric space#Notions of metric space equivalence}}
+
== Norm induced metric ==
  
== Norm induced metric ==
 
{{anchor|Norm induced metric|Relation of norms and metrics}}
 
<!-- linked from [[Relation of norms and metrics]] -->
 
 
Norms on vector spaces are equivalent to certain metrics, namely homogeneous, translation-invariant ones. In other words, every norm determines a metric, and some metrics determine a norm.
 
Norms on vector spaces are equivalent to certain metrics, namely homogeneous, translation-invariant ones. In other words, every norm determines a metric, and some metrics determine a norm.
  
Given a [[normed vector space]] <math>(X, \|\cdot\|)</math> we can define a metric <math>d</math> on <math>X,</math> called the {{em|metric induced by <math>\| \cdot \|</math>}} or simply the {{em|norm induced metric}}, by
+
Given a normed vector space <math>(X, \|\cdot\|)</math> we can define a metric <math>d</math> on <math>X,</math> called the ''metric induced by <math>\| \cdot \|</math>'' or simply the ''norm induced metric'', by
 
:<math>d(x,y) := \| x-y\|.</math>
 
:<math>d(x,y) := \| x-y\|.</math>
The metric <math>d</math> is said to be {{em|induced by}} the norm <math>\|\cdot\|.</math>
+
The metric <math>d</math> is said to be ''induced by'' the norm <math>\|\cdot\|.</math>
  
Conversely{{sfn|Narici|Beckenstein|2011|pp=47-66}} if a metric <math>d</math> on a [[vector space]] <math>X</math> satisfies the properties
+
Conversely if a metric <math>d</math> on a vector space <math>X</math> satisfies the properties
 
* Translation invariance: <math>d(x,y) = d(x+a,y+a)</math>;
 
* Translation invariance: <math>d(x,y) = d(x+a,y+a)</math>;
* [[Absolute homogeneity]]: <math>d(\alpha x, \alpha y) = |\alpha| d(x,y)</math>;
+
* Absolute homogeneity: <math>d(\alpha x, \alpha y) = |\alpha| d(x,y)</math>;
then a [[norm (mathematics)|norm]] on <math>X</math> may be defined by
+
then a norm on <math>X</math> may be defined by
  
 
:<math>\|x\| := d(x,0)</math>
 
:<math>\|x\| := d(x,0)</math>
Line 89: Line 85:
 
where the metric induced by this norm is the original given metric <math>d.</math>  
 
where the metric induced by this norm is the original given metric <math>d.</math>  
  
Similarly, a [[seminorm]] induces a pseudometric (see below), and a homogeneous, translation invariant pseudometric induces a seminorm.
+
Similarly, a seminorm induces a pseudometric (see below), and a homogeneous, translation invariant pseudometric induces a seminorm.
  
 
==Metrics on multisets==
 
==Metrics on multisets==
We can generalize the notion of a metric from a distance between two elements to a distance between two nonempty finite multisets of elements. A [[multiset]] is a generalization of the notion of a [[set (mathematics)|set]] such that an element can occur more than once.  Define <math>Z=XY</math> if
+
We can generalize the notion of a metric from a distance between two elements to a distance between two nonempty finite multisets of elements. A multiset is a generalization of the notion of a set such that an element can occur more than once.  Define <math>Z=XY</math> if
 
<math>Z</math> is the multiset consisting of the elements of the multisets <math>X</math> and <math>Y</math>, that is, if <math>x</math> occurs once in <math>X</math> and once in <math>Y</math> then it occurs twice in <math>Z</math>.  
 
<math>Z</math> is the multiset consisting of the elements of the multisets <math>X</math> and <math>Y</math>, that is, if <math>x</math> occurs once in <math>X</math> and once in <math>Y</math> then it occurs twice in <math>Z</math>.  
 
A distance function
 
A distance function
<math>d</math> on the set of nonempty finite multisets is a metric{{sfn|Vitányi|2011}} if
+
<math>d</math> on the set of nonempty finite multisets is a metric if
#  <math>d(X)=0</math> if all elements of <math>X</math> are equal and <math>d(X) > 0</math> otherwise ([[positive definiteness]]), that is, ([[Non-negative|non-negativity]] plus [[identity of indiscernibles]])
+
#  <math>d(X)=0</math> if all elements of <math>X</math> are equal and <math>d(X) > 0</math> otherwise (positive definiteness), that is, (non-negativity plus identity of indiscernibles)
# <math>d(X)</math> is invariant under all permutations of <math>X</math> ([[symmetry]])
+
# <math>d(X)</math> is invariant under all permutations of <math>X</math> (symmetry)
# <math>d(XY) \leq d(XZ)+d(ZY)</math> ([[triangle inequality]])
+
# <math>d(XY) \leq d(XZ)+d(ZY)</math> (triangle inequality)
 
Note that the familiar metric between two elements results if the multiset <math>X</math> has two elements in 1 and 2 and the multisets <math>X,Y,Z</math> have one element each in 3. For instance if <math>X</math> consists of two occurrences of <math>x</math>, then <math>d(X)=0</math> according to 1.
 
Note that the familiar metric between two elements results if the multiset <math>X</math> has two elements in 1 and 2 and the multisets <math>X,Y,Z</math> have one element each in 3. For instance if <math>X</math> consists of two occurrences of <math>x</math>, then <math>d(X)=0</math> according to 1.
  
A simple example is the set of all nonempty finite multisets <math>X</math>  of integers with <math>d(X)=\max\{x: x \in X\}- \min\{x:x \in X\}</math>. More complex examples are [[information distance]] in multisets;{{sfn|Vitányi|2011}} and [[normalized compression distance]] (NCD) in multisets.{{sfn|Cohen|Vitányi|2012}}
+
A simple example is the set of all nonempty finite multisets <math>X</math>  of integers with <math>d(X)=\max\{x: x \in X\}- \min\{x:x \in X\}</math>. More complex examples are information distance in multisets; and normalized compression distance (NCD) in multisets.
  
 
== Generalized metrics ==
 
== Generalized metrics ==
There are numerous ways of relaxing the axioms of metrics, giving rise to various notions of generalized metric spaces. These generalizations can also be combined. The terminology used to describe them is not completely standardized. Most notably, in [[functional analysis]] pseudometrics often come from [[seminorm]]s on vector spaces, and so it is natural to call them "semimetrics". This conflicts with the use of the term in [[topology]].
+
There are numerous ways of relaxing the axioms of metrics, giving rise to various notions of generalized metric spaces. These generalizations can also be combined. The terminology used to describe them is not completely standardized. Most notably, in functional analysis pseudometrics often come from seminorms on vector spaces, and so it is natural to call them "semimetrics". This conflicts with the use of the term in topology.
  
 
=== Extended metrics ===
 
=== Extended metrics ===
Some authors allow the distance function ''d'' to attain the value ∞, i.e. distances are non-negative numbers on the [[extended real number line]].  
+
Some authors allow the distance function ''d'' to attain the value ∞, i.e. distances are non-negative numbers on the extended real number line.  
 
Such a function is called an ''extended metric'' or "∞-metric".  
 
Such a function is called an ''extended metric'' or "∞-metric".  
Every extended metric can be transformed to a finite metric such that the metric spaces are equivalent as far as notions of [[topology]] (such as [[continuous function (topology)|continuity]] or [[limit (mathematics)|convergence]]) are concerned. This can be done using a [[Subadditive function|subadditive]] monotonically increasing bounded function which is zero at zero, e.g. ''d''&prime;(''x'', ''y'') = ''d''(''x'', ''y'') / (1 + ''d''(''x'', ''y'')) or ''d''&Prime;(''x'', ''y'') = min(1, ''d''(''x'', ''y'')).
+
Every extended metric can be transformed to a finite metric such that the metric spaces are equivalent as far as notions of topology (such as continuity or convergence) are concerned. This can be done using a subadditive monotonically increasing bounded function which is zero at zero, e.g. ''d''&prime;(''x'', ''y'') = ''d''(''x'', ''y'') / (1 + ''d''(''x'', ''y'')) or ''d''&Prime;(''x'', ''y'') = min(1, ''d''(''x'', ''y'')).
  
The requirement that the metric take values in {{closed-open|0,∞}} can even be relaxed to consider metrics with values in other [[directed set]]s.  The reformulation of the axioms in this case leads to the construction of [[uniform space]]s: topological spaces with an abstract structure enabling one to compare the local topologies of different points.
+
The requirement that the metric take values in [0,∞) can even be relaxed to consider metrics with values in other directed sets.  The reformulation of the axioms in this case leads to the construction of uniform spaces: topological spaces with an abstract structure enabling one to compare the local topologies of different points.
  
 
===Pseudometrics===
 
===Pseudometrics===
{{Main|Pseudometric space}}
+
A ''pseudometric'' on ''X'' is a function <math>d: X \times X \to \R</math> which satisfies the axioms for a metric, except that instead of the second (identity of indiscernibles) only ''d''(''x'',''x'') = 0 for all ''x'' is required. In other words, the axioms for a pseudometric are:
A ''pseudometric'' on ''X'' is a function <math>d: X \times X \to \R</math> which satisfies the axioms for a metric, except that instead of the second (identity of indiscernibles) only {{nowrap|1=''d''(''x'',''x'') = 0}} for all ''x'' is required. In other words, the axioms for a pseudometric are:
 
  
 
# ''d''(''x'', ''y'') ≥ 0
 
# ''d''(''x'', ''y'') ≥ 0
Line 123: Line 118:
 
# ''d''(''x'', ''z'') ≤ ''d''(''x'', ''y'') + ''d''(''y'', ''z'').
 
# ''d''(''x'', ''z'') ≤ ''d''(''x'', ''y'') + ''d''(''y'', ''z'').
  
In some contexts, pseudometrics are referred to as ''semimetrics'' because of their relation to [[seminorm]]s.
+
In some contexts, pseudometrics are referred to as ''semimetrics'' because of their relation to seminorms.
  
 
===Quasimetrics===
 
===Quasimetrics===
Occasionally, a '''quasimetric''' is defined as a function that satisfies all axioms for a metric with the possible exception of symmetry.<ref>{{harvtxt|Steen|Seebach|1995}}; {{harvtxt|Smyth|1987}}</ref> The name of this generalisation is not entirely standardized.<ref>{{harvtxt|Rolewicz|1987}} calls them "semimetrics". That same term is also frequently used for two other generalizations of metrics.</ref>
+
Occasionally, a '''quasimetric''' is defined as a function that satisfies all axioms for a metric with the possible exception of symmetry. The name of this generalisation is not entirely standardized.
  
 
# ''d''(''x'', ''y'') ≥ 0 (''positivity'')
 
# ''d''(''x'', ''y'') ≥ 0 (''positivity'')
Line 133: Line 128:
 
# ''d''(''x'', ''z'') ≤ ''d''(''x'', ''y'') + ''d''(''y'', ''z'') (''triangle inequality'')
 
# ''d''(''x'', ''z'') ≤ ''d''(''x'', ''y'') + ''d''(''y'', ''z'') (''triangle inequality'')
  
Quasimetrics are common in real life. For example, given a set ''X'' of mountain villages, the typical walking times between elements of ''X'' form a quasimetric because travel up hill takes longer than travel down hill. Another example is a [[taxicab geometry]] topology having one-way streets, where a path from point ''A'' to point ''B'' comprises a different set of streets than a path from ''B'' to ''A''.
+
Quasimetrics are common in real life. For example, given a set ''X'' of mountain villages, the typical walking times between elements of ''X'' form a quasimetric because travel up hill takes longer than travel down hill. Another example is a taxicab geometry topology having one-way streets, where a path from point ''A'' to point ''B'' comprises a different set of streets than a path from ''B'' to ''A''.
  
 
A quasimetric on the reals can be defined by setting
 
A quasimetric on the reals can be defined by setting
 
:''d''(''x'', ''y'') = ''x'' − ''y'' if ''x'' ≥ ''y'', and
 
:''d''(''x'', ''y'') = ''x'' − ''y'' if ''x'' ≥ ''y'', and
 
:''d''(''x'', ''y'') = 1 otherwise. The 1 may be replaced by infinity or by <math>1 + 10^{(y-x)}</math>.
 
:''d''(''x'', ''y'') = 1 otherwise. The 1 may be replaced by infinity or by <math>1 + 10^{(y-x)}</math>.
The topological space underlying this quasimetric space is the [[Sorgenfrey line]]. This space describes the process of [[Filing (metalworking)|filing down]] a metal stick: it is easy to reduce its size, but it is difficult or impossible to grow it.
+
The topological space underlying this quasimetric space is the Sorgenfrey line. This space describes the process of filing down a metal stick: it is easy to reduce its size, but it is difficult or impossible to grow it.
  
 
If ''d'' is a quasimetric on ''X'', a metric ''d<nowiki>'</nowiki>'' on ''X'' can be formed by taking
 
If ''d'' is a quasimetric on ''X'', a metric ''d<nowiki>'</nowiki>'' on ''X'' can be formed by taking
:''d<nowiki>'</nowiki>''(''x'', ''y'') = {{sfrac|2}}(''d''(''x'', ''y'') + ''d''(''y'', ''x'')).
+
:''d<nowiki>'</nowiki>''(''x'', ''y'') = <math>\frac{1}{2}</math>(''d''(''x'', ''y'') + ''d''(''y'', ''x'')).
  
 
=== Important cases of generalized metrics ===
 
=== Important cases of generalized metrics ===
In [[differential geometry]], one considers a [[metric tensor]], which can be thought of as an "infinitesimal" quadratic metric function. This is defined as a [[nondegenerate]] symmetric [[bilinear form]] on the [[tangent space]] of a [[manifold]] with an appropriate [[differentiability]] requirement.  While these are not metric functions as defined in this article, they induce what is called a pseudo-semimetric function by [[Antiderivative|integration]] of its square root along a path through the manifold. If one imposes the positive-definiteness requirement of an [[inner product]] on the metric tensor, this restricts to the case of a [[Riemannian manifold]], and the path integration yields a metric.
+
In differential geometry, one considers a metric tensor, which can be thought of as an "infinitesimal" quadratic metric function. This is defined as a nondegenerate symmetric bilinear form on the tangent space of a manifold with an appropriate differentiability requirement.  While these are not metric functions as defined in this article, they induce what is called a pseudo-semimetric function by integration of its square root along a path through the manifold. If one imposes the positive-definiteness requirement of an inner product on the metric tensor, this restricts to the case of a Riemannian manifold, and the path integration yields a metric.
  
In [[general relativity]] the related concept is a [[metric tensor (general relativity)]] which expresses the structure of a [[pseudo-Riemannian manifold]]. Though the term "metric" is used, the fundamental idea is different because there are non-zero [[null vector]]s in the tangent space of these manifolds, and vectors can have negative squared norms. This generalized view of "metrics", in which zero distance does ''not'' imply identity, has crept into some mathematical writing too:<ref>{{harvtxt|Parrott|1987}}: "This bilinear form is variously called the ''Lorentz metric'', or ''Minkowski metric'' or ''metric tensor''"; {{harvtxt|Cecil|2008}}: "We call this scalar product the ''Lorentz metric''"</ref>
+
In general relativity the related concept is a metric tensor (general relativity) which expresses the structure of a pseudo-Riemannian manifold. Though the term "metric" is used, the fundamental idea is different because there are non-zero null vectors in the tangent space of these manifolds, and vectors can have negative squared norms. This generalized view of "metrics", in which zero distance does ''not'' imply identity, has crept into some mathematical writing too
  
  

Latest revision as of 14:31, 29 October 2021

An illustration comparing the taxicab metric to the Euclidean metric on the plane: According to the taxicab metric the red, yellow, and blue paths have the same length (12). According to the Euclidean metric, the green path has length , and is the unique shortest path.

In mathematics, a metric or distance function is a function that gives a distance between each pair of point elements of a set. A set with a metric is called a metric space. A metric induces a topology on a set, but not all topologies can be generated by a metric. A topological space whose topology can be described by a metric is called metrizable.

One important source of metrics in differential geometry are metric tensors, bilinear forms that may be defined from the tangent vectors of a differentiable manifold onto a scalar. A metric tensor allows distances along curves to be determined through integration, and thus determines a metric.

Definition

A metric on a set X is a function (called distance function or simply distance)

where is the set of non-negative real numbers and for all , the following three axioms are satisfied:

1. identity of indiscernibles
2. symmetry
3. triangle inequality

A metric (as defined) is a non-negative real-valued function. This, together with axiom 1, provides a separation condition, where distinct or separate points are precisely those that have a positive distance between them.

The requirement that have a range of is a clarifying (but unnecessary) restriction in the definition, for if we had any function that satisfied the same three axioms, the function could be proven to still be non-negative as follows (using axioms 1, 3, and 2 in that order):

which implies .

A metric is called an ultrametric if it satisfies the following stronger version of the triangle inequality where points can never fall 'between' other points:

for all

A metric d on X is called intrinsic if any two points x and y in X can be joined by a curve with length arbitrarily close to d(x, y).

A metric d on a group G (written multiplicatively) is said to be left-invariant (resp. right invariant) if we have

[resp. ]

for all x, y, and z in G.

A metric on a commutative additive group is said to be translation invariant if for all or equivalently, if for all Every vector space is also a commutative additive group and a metric on a real or complex vector space that is induced by a norm is always translation invariant. A metric on a real or complex vector space is induced by a norm if and only if it is translation invariant and absolutely homogeneous, where the latter means that for all scalars and all in which case the function defines a norm on and the canonical metric induced by is equal to

Notes

These conditions express intuitive notions about the concept of distance. For example, that the distance between distinct points is positive and the distance from x to y is the same as the distance from y to x. The triangle inequality means that the distance from x to z via y is at least as great as from x to z directly. Euclid in his work stated that the shortest distance between two points is a line; that was the triangle inequality for his geometry.

Examples

  • The discrete metric: if x = y then d(x,y) = 0. Otherwise, d(x,y) = 1.
  • The Euclidean metric is translation and rotation invariant.
  • The taxicab metric is translation invariant.
  • More generally, any metric induced by a norm is translation invariant.
  • If is a sequence of seminorms defining a (locally convex) topological vector space E, then
    is a metric defining the same topology. (One can replace by any summable sequence of strictly positive numbers.)
  • The normed space is a Banach space where the absolute value is a norm on the real line that induces the usual Euclidean topology on Define a metric on by for all Just like 's induced metric, the metric also induces the usual Euclidean topology on R. However, is not a complete metric because the sequence defined by is a -Cauchy sequence but it does not converge to any point of R. As a consequence of not converging, this -Cauchy sequence cannot be a Cauchy sequence in (i.e. it is not a Cauchy sequence with respect to the norm ) because if it was -Cauchy, then the fact that is a Banach space would imply that it converges (a contradiction).
  • Graph metric, a metric defined in terms of distances in a certain graph.
  • The Hamming distance in coding theory.
  • Riemannian metric, a type of metric function that is appropriate to impose on any differentiable manifold. For any such manifold, one chooses at each point p a symmetric, positive definite, bilinear form L: Tp × TpR on the tangent space Tp at p, doing so in a smooth manner. This form determines the length of any tangent vector v on the manifold, via the definition . Then for any differentiable path on the manifold, its length is defined as the integral of the length of the tangent vector to the path at any point, where the integration is done with respect to the path parameter. Finally, to get a metric defined on any pair {x, y} of points of the manifold, one takes the infimum, over all paths from x to y, of the set of path lengths. A smooth manifold equipped with a Riemannian metric is called a Riemannian manifold.
  • The Fubini–Study metric on complex projective space. This is an example of a Riemannian metric.
  • String metrics, such as Levenshtein distance and other string edit distances, define a metric over strings.
  • Graph edit distance defines a distance function between graphs.
  • The Wasserstein metric is a distance function defined between two probability distributions.
  • The Finsler metric is a continuous nonnegative function F: TM → [0,+∞) defined on the tangent bundle.

Equivalence of metrics

For a given set X, two metrics d1 and d2 are called topologically equivalent (uniformly equivalent) if the identity mapping

id: (X,d1) → (X,d2)

is a homeomorphism (uniform isomorphism).

For example, if is a metric, then and are metrics equivalent to

Norm induced metric

Norms on vector spaces are equivalent to certain metrics, namely homogeneous, translation-invariant ones. In other words, every norm determines a metric, and some metrics determine a norm.

Given a normed vector space we can define a metric on called the metric induced by or simply the norm induced metric, by

The metric is said to be induced by the norm

Conversely if a metric on a vector space satisfies the properties

  • Translation invariance: ;
  • Absolute homogeneity: ;

then a norm on may be defined by

where the metric induced by this norm is the original given metric

Similarly, a seminorm induces a pseudometric (see below), and a homogeneous, translation invariant pseudometric induces a seminorm.

Metrics on multisets

We can generalize the notion of a metric from a distance between two elements to a distance between two nonempty finite multisets of elements. A multiset is a generalization of the notion of a set such that an element can occur more than once. Define if is the multiset consisting of the elements of the multisets and , that is, if occurs once in and once in then it occurs twice in . A distance function on the set of nonempty finite multisets is a metric if

  1. if all elements of are equal and otherwise (positive definiteness), that is, (non-negativity plus identity of indiscernibles)
  2. is invariant under all permutations of (symmetry)
  3. (triangle inequality)

Note that the familiar metric between two elements results if the multiset has two elements in 1 and 2 and the multisets have one element each in 3. For instance if consists of two occurrences of , then according to 1.

A simple example is the set of all nonempty finite multisets of integers with . More complex examples are information distance in multisets; and normalized compression distance (NCD) in multisets.

Generalized metrics

There are numerous ways of relaxing the axioms of metrics, giving rise to various notions of generalized metric spaces. These generalizations can also be combined. The terminology used to describe them is not completely standardized. Most notably, in functional analysis pseudometrics often come from seminorms on vector spaces, and so it is natural to call them "semimetrics". This conflicts with the use of the term in topology.

Extended metrics

Some authors allow the distance function d to attain the value ∞, i.e. distances are non-negative numbers on the extended real number line. Such a function is called an extended metric or "∞-metric". Every extended metric can be transformed to a finite metric such that the metric spaces are equivalent as far as notions of topology (such as continuity or convergence) are concerned. This can be done using a subadditive monotonically increasing bounded function which is zero at zero, e.g. d′(x, y) = d(x, y) / (1 + d(x, y)) or d″(x, y) = min(1, d(x, y)).

The requirement that the metric take values in [0,∞) can even be relaxed to consider metrics with values in other directed sets. The reformulation of the axioms in this case leads to the construction of uniform spaces: topological spaces with an abstract structure enabling one to compare the local topologies of different points.

Pseudometrics

A pseudometric on X is a function which satisfies the axioms for a metric, except that instead of the second (identity of indiscernibles) only d(x,x) = 0 for all x is required. In other words, the axioms for a pseudometric are:

  1. d(x, y) ≥ 0
  2. d(x, x) = 0 (but possibly d(x, y) = 0 for some distinct values xy.)
  3. d(x, y) = d(y, x)
  4. d(x, z) ≤ d(x, y) + d(y, z).

In some contexts, pseudometrics are referred to as semimetrics because of their relation to seminorms.

Quasimetrics

Occasionally, a quasimetric is defined as a function that satisfies all axioms for a metric with the possible exception of symmetry. The name of this generalisation is not entirely standardized.

  1. d(x, y) ≥ 0 (positivity)
  2. d(x, y) = 0   if and only if   x = y (positive definiteness)
  3. d(x, y) = d(y, x) (symmetry, dropped)
  4. d(x, z) ≤ d(x, y) + d(y, z) (triangle inequality)

Quasimetrics are common in real life. For example, given a set X of mountain villages, the typical walking times between elements of X form a quasimetric because travel up hill takes longer than travel down hill. Another example is a taxicab geometry topology having one-way streets, where a path from point A to point B comprises a different set of streets than a path from B to A.

A quasimetric on the reals can be defined by setting

d(x, y) = xy if xy, and
d(x, y) = 1 otherwise. The 1 may be replaced by infinity or by .

The topological space underlying this quasimetric space is the Sorgenfrey line. This space describes the process of filing down a metal stick: it is easy to reduce its size, but it is difficult or impossible to grow it.

If d is a quasimetric on X, a metric d' on X can be formed by taking

d'(x, y) = (d(x, y) + d(y, x)).

Important cases of generalized metrics

In differential geometry, one considers a metric tensor, which can be thought of as an "infinitesimal" quadratic metric function. This is defined as a nondegenerate symmetric bilinear form on the tangent space of a manifold with an appropriate differentiability requirement. While these are not metric functions as defined in this article, they induce what is called a pseudo-semimetric function by integration of its square root along a path through the manifold. If one imposes the positive-definiteness requirement of an inner product on the metric tensor, this restricts to the case of a Riemannian manifold, and the path integration yields a metric.

In general relativity the related concept is a metric tensor (general relativity) which expresses the structure of a pseudo-Riemannian manifold. Though the term "metric" is used, the fundamental idea is different because there are non-zero null vectors in the tangent space of these manifolds, and vectors can have negative squared norms. This generalized view of "metrics", in which zero distance does not imply identity, has crept into some mathematical writing too


Licensing

Content obtained and/or adapted from: