(Continuous) Fréchet distance between two open polygonal curves.
Let \(f: [0, 1] \to \Omega\) and \(g: [0, 1] \to \Omega\) be curves
where \(\Omega\) is a metric space. The Fréchet distance between
\(f\) and \(g\) is defined as
where \(\alpha, \beta: [0, 1] \to [0, 1]\) are continuous non-decreasing
surjections and \(\lVert \cdot \rVert\) is the underlying metric, which
is the Euclidean metric in this implementation.
Parameters:
Parray_like
A \(p\) by \(n\) array of \(p\) vertices in an
\(n\)-dimensional space.
Qarray_like
A \(q\) by \(n\) array of \(q\) vertices in an
\(n\)-dimensional space.
Returns:
distdouble
The (continuous) Fréchet distance between P and Q, NaN if any vertice
is empty.
Raises:
ValueError
If P and Q are not 2-dimensional arrays with same number of columns.
Notes
This function implements Alt and Godau’s algorithm [1].
Discrete Fréchet distance between two open polygonal curves.
Let \(\{P_0, P_1, ..., P_n\}\) and \(\{Q_0, Q_1, ..., Q_m\}\) be
polyline vertices in metric space. The discrete Fréchet distance between
two polylines is defined as
where \(C\) is a nondecreasing coupling over
\(\{0, ..., n\} \times \{0, ..., m\}\), starting from \((0, 0)\) and
ending with \((n, m)\). \(\lVert \cdot \rVert\) is the underlying
metric, which is the Euclidean metric in this implementation.
Parameters:
Parray_like
An \(p\) by \(n\) array of \(p\) vertices in an
\(n\)-dimensional space.
Qarray_like
An \(q\) by \(n\) array of \(q\) vertices in an
\(n\)-dimensional space.
Returns:
distdouble
The discrete Fréchet distance between P and Q, NaN if any vertice
is empty.
Raises:
ValueError
If P and Q are not 2-dimensional arrays with same number of columns.
Notes
This function implements Eiter and Mannila’s algorithm [2].
Let \(\{P_0, P_1, ..., P_n\}\) and \(\{Q_0, Q_1, ..., Q_m\}\) be
polyline vertices in metric space. The dynamic time warping distance between
two polylines is defined as
where \(C\) is a nondecreasing coupling over
\(\{0, ..., n\} \times \{0, ..., m\}\), starting from \((0, 0)\) and
ending with \((n, m)\). \(\lVert \cdot \rVert\) is the underlying
metric, which is the Euclidean metric in this implementation.
Parameters:
Parray_like
A \(p\) by \(n\) array of \(p\) vertices in an
\(n\)-dimensional space.
Qarray_like
A \(q\) by \(n\) array of \(q\) vertices in an
\(n\)-dimensional space.
Returns:
distdouble
The dynamic time warping distance between P and Q, NaN if any vertice
is empty.
Raises:
ValueError
If P and Q are not 2-dimensional arrays with same number of columns.
curvesimilarities.integfrechet.ifd(P, Q, delta)[source]#
Integral Fréchet distance between two open polygonal curves.
Let \(f, g: [0, 1] \to \Omega\) be curves defined in a metric space
\(\Omega\). Let \(\alpha, \beta: [0, 1] \to [0, 1]\) be continuous
non-decreasing surjections, and define \(\pi: [0, 1] \to [0, 1] \times
[0, 1]\) such that \(\pi(t) = \left(\alpha(t), \beta(t)\right)\).
The integral Fréchet distance between \(f\) and \(g\) is defined as
where \(\delta\left(\pi(t)\right)\) is a distance between
\(f\left(\alpha(t)\right)\) and \(g\left(\beta(t)\right)\) in
\(\Omega\) and \(\lVert \cdot \rVert\) is a norm in \([0, 1]
\times [0, 1]\). In this implementation, we use the Euclidean distance
for \(\delta\) and the Manhattan norm for \(\lVert \cdot \rVert\).
Parameters:
Parray_like
A \(p\) by \(n\) array of \(p\) vertices in an
\(n\)-dimensional space.
Qarray_like
A \(q\) by \(n\) array of \(q\) vertices in an
\(n\)-dimensional space.
deltadouble
Maximum length of edges between Steiner points.
Returns:
distdouble
The integral Fréchet distance between P and Q, NaN if any vertice
is empty or both vertices consist of a single point.
Raises:
ValueError
If P and Q are not 2-dimensional arrays with same number of columns.