Discrete Fréchet distance

Description

The discrete Frechet distance dells with the easier variant, where the input is two sequence of points, and the distance is the minimum max-leash that is needed, if two "frogs" jumps in a synchronized fashion along the two sequences, starting at the start of the sequences, and end in the end of the sequences. At each point only one frog jumps, and it can jump only forward by one position in the sequence of points it is on.

The basic solution to this is dynamic programming, which is similar in nature to edit-distance.

We also present the retractable variant, which tries to use a leash that is as short as possible at any point in time.

Finally, we also present a variant for the "continuous" variant, where one samples points along two polygons, and then compute their discrete Frechet distance. This is the "standard" way of using the discrete Frechet distance for the continuous problem. It provides inferior results than the continuous variants, but it is simple enough to implement, and it is thus provided.

Functions documentation

FrechetDist.frechet_d_compute — Function
frechet_d_compute

Computes the discrete Fréchet distance between the vertex sequences of P and Q, over single-step couplings: one index advances at a time (no diagonal moves), so the result can exceed the textbook discrete Fréchet distance, which allows both indices to advance together. m.leash is the distance.

source
FrechetDist.frechet_d_r_compute — Function
frechet_d_r_compute

Compute the locally optimal discrete Frechet distance. Essentially the discrete Frechet distance plus a Prim/Dijkstra algorithm, for the discrete case, modified to be retractable – that is, to minimize the maximum bottleneck edge being computed.

Note, the function still allocates quadratic space for the lookup tables. This does not seem to matter, but it might be worth fixing in future versions.

source
FrechetDist.frechet_d_r_compute_sample — Function
frechet_d_r_compute_sample( polya, polyb, n, f_lopt = true )

Computes the discrete Frechet distance between the two curves by sampling them.

It first samples the two curves uniformly: about n points in total, split between the curves in proportion to their lengths. Each sample also keeps every vertex of its curve, so it can have up to that many more points.

Arguments

  • n: about the number of sample points to place on the two curves together, besides their vertices.

  • f_lopt true: Use the retractable Frechet distance version false: Use the standard discrete Frechet version.

source
FrechetDist.DTW_d_compute — Function
DTW_d_compute

Compute the Dynamic Time Warping distance between two polygons: the
minimum, over single-step discrete couplings (one index advances at a
time), of the sum of the leash lengths. The price is returned in
`m.sol_value`; `m.leash` is the longest leash of the optimal coupling.
Ties between couplings of equal price are broken in a fixed way: at each cell,
a step along `Q` is preferred to an equally cheap step along `P`.
source