Discrete Fréchet distance
Computes the discrete Fréchet distance between two curves. The Fréchet distance between two curves in a metric space is a measure of the similarity between the curves. The discrete Fréchet distance may be used for approximately computing the Fréchet distance between two arbitrary curves, as an alternative to using the exact Fréchet distance between a polygonal approximation of the curves or an approximation of this value.
This is a Python 3.* implementation of the algorithm produced in Eiter, T. and Mannila, H., 1994. Computing discrete Fréchet distance. Tech. Report CD-TR 94/64, Information Systems Department, Technical University of Vienna.
Function dF(P, Q): real;
input: polygonal curves P = (u1, . . . , up) and Q = (v1, . . . , vq).
return: δdF (P, Q)
ca : array [1..p, 1..q] of real;
function c(i, j): real;
begin
if ca(i, j) > −1 then return ca(i, j)
elsif i = 1 and j = 1 then ca(i, j) := d(u1, v1)
elsif i > 1 and j = 1 then ca(i, j) := max{ c(i − 1, 1), d(ui, v1) }
elsif i = 1 and j > 1 then ca(i, j) := max{ c(1, j − 1), d(u1, vj ) }
elsif i > 1 and j > 1 then ca(i, j) :=
max{ min(c(i − 1, j), c(i − 1, j − 1), c(i, j − 1)), d(ui, vj ) }
else ca(i, j) = ∞
return ca(i, j);
end; /* function c */
begin
for i = 1 to p do for j = 1 to q do ca(i, j) := −1.0;
return c(p, q);
end.
Parameters
P : Input curve - two dimensional array of points
Q : Input curve - two dimensional array of points
Returns
dist: float64
The discrete Frechet distance between curves `P` and `Q`.
Examples
>>> from frechetdist import frdist
>>> P=[[1,1], [2,1], [2,2]]
>>> Q=[[2,2], [0,1], [2,4]]
>>> frdist(P,Q)
>>> 2.0
>>> P=[[1,1], [2,1], [2,2]]
>>> Q=[[1,1], [2,1], [2,2]]
>>> frdist(P,Q)
>>> 0
Release files for frechetdist 0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| frechetdist-0.6.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| frechetdist-0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / frechetdist-0.6.tar.gz
| Download URL | frechetdist-0.6.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab1d2592932cfa37e36a29e6df903592a366b86a91e395aa5866ad1cb53ad162
|
|
BLAKE2b-256 checksum How to use checksums |
ebbd6b3ddd08ec7fc63d082215b924127f8fffc6f9743ccd0f2d3c05aad28544
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8
|
Release files / frechetdist-0.6-py3-none-any.whl
| Download URL | frechetdist-0.6-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c451619f1de6739d57c13981c34725a603c1068953d099b8cb07fa08d64f1072
|
|
BLAKE2b-256 checksum How to use checksums |
5af8fdd0d7ca48066152f4a80cd645a4f65e909350ee9b2f6026c6d917d73b62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8
|