Orientation-Preserving Vectorized Distance Between Curves
OOrientation-Preserving Vectorized Distance Between Curves
Jeff M. Phillips and Hasan Pourmahmood-AghababaUniversity of Utah jeffp|[email protected]
Abstract
We introduce an orientation-preserving landmark-based distance for continuous curves, which can beviewed as an alternative to the Fr´echet or Dynamic Time Warping distances. This measure retains manyof the properties of those measures, and we prove some relations, but can be interpreted as a Euclideandistance in a particular vector space. Hence it is significantly easier to use, faster for general nearestneighbor queries, and allows easier access to classification results than those measures. It is based onthe signed distance function to the curves or other objects from a fixed set of landmark points. We alsoprove new stability properties with respect to the choice of landmark points, and along the way introducea concept called signed local feature size (slfs) which parameterizes these notions. Slfs explains thecomplexity of shapes such as non-closed curves where the notion of local orientation is in dispute –but is more general than the well-known concept of (unsigned) local feature size, and is for instanceinfinite for closed simple curves. Altogether, this work provides a novel, simple, and powerful methodfor oriented shape similarity and analysis.
Jeff Phillips thanks his support from NSF CCF-1350888, CNS- 1514520, CNS-1564287, and IIS-1816149. a r X i v : . [ c s . C G ] A ug Introduction
The Fr´echet distance [4] is a very popular distance between curves; it has spurred significantly practical workimproving its empirical computational time [13] (including a recent GIS Cup challenge [46, 10, 15, 29] andinclusion in sklearn) and has been the subject of much algorithmic studies on its computational complex-ity [11, 1, 14]. While in some practical settings it can be computed in near-linear time [25], there existssettings where it may require near-quadratic time – essentially reverting to dynamic programming [11].The interest in studying the Fr´echet distance (and similar distances like the discrete Fr´echet distance [30],Dynamic Time Warping [36], edit distance with real penalties [21]) has grown recently due to the veryreal desire to apply them to data analysis. Large corpuses of trajectories have arisen through collectionof GPS traces of people [49], vehicles [23], or animals [16], as well as other shapes such as letters [47],time series [26], and more general shapes [5]. What is common about these measures, and what separatesthem from alternatives such as the Hausdorff distance is that they capture the direction or orientation ofthe object. However, this enforcing of an ordering seems be directly tied to the near-quadratic hardnessresults [11], deeply linked with other tasks like edit distance [12, 9].Moreover, for data analysis on large data sets, not only is fast computation needed, but other operationslike fast nearest-neighbor search or inner products. While a lot of progress has been made in the case ofFr´echet distance and the like [45, 48, 24, 28, 27, 31], these operations are still comparatively slow andlimited. For instance, some of the best fast nearest neighbor search for LSH have bounds [31], for discreteFr´echet distance on n curves with m waypoints can answer a query within ε using O ( m ) time, butrequiring n · O ((1 /ε ) m ) space; or if we reduce the space to something reasonable like O ( n log n + mn ) ,then a query in O ( m log n ) time can provide only an O ( m ) approximation [28].On the other hand, fast nearest neighbor search for Euclidean distance is far more mature, with betterLSH bounds, but also quite practical algorithms [3, 42]. Moreover, most machine learning libraries assumeas input Euclidean data, or for other standard data types like images [34] or text [39, 38] have sophisticatedmethods to map to Euclidean space. However, Fr´echet distance is known not to be embeddable into aEuclidean vector space without quite high distortion [33, 28]. Embeddings first.
This paper on the other hand starts with the goal of embedding ordered/oriented curve(and shape) data to a Euclidean vector space, where inner products are natural, fast nearest neighbor search iseasily available, and it can directly be dropped into any machine learning or other data analysis framework.This builds on recent work with a similar goals for halfspaces, curves, and other shapes [40, 41]. But thatwork did not encode orientation. This orientation preserving aspect of these distances is clearly importantfor some applications; it is needed to say distinguish someone going to work versus returning from work.Why might Fr´echet be better for data analysis than discrete Fr´echet or DTW or the many other distances?One can potentially point to long segments and no need to discretize, or (quasi-)metric properties. Regard-less, an equalizer is in determining how well a distance models data is the prediction error for classificationtasks; such tasks demonstrate how well the distances encode what truely matters on real tasks. The previousvectorized representations matched or outperformed a dozen other measures [40]. In this paper, we showan oriented distance performs similarly (although not quite as well in general tasks), but on a synthetic taskwhere orientation is essential, does better than these non-orientation preserving measures. Moreover, byextending properties from similar, but non-orientable vectorized distances [40, 41], our proposed distanceinherits metric properties, can handle long segments, and also captures curve orientation.More specifically, our approach assumes all objects are in a bounded domain Ω a subset of R d (typically R ). This domain contains a set of landmark points Q , which might constitute a continuous uniform measureover Ω , or a finite sample approximation of that distribution. With respect to an object γ , each landmark q i ∈ Q generates a value v q i ( γ ) . Each of these values v q i ( γ ) can correspond with the i th coordinate ina vector v Q ( γ ) , which is finite (with | Q | = n -dimensions) if Q is finite. Then the distance between twoobjects γ and γ (cid:48) is the square-root of the average squared distance of these values – or the Euclidean distance1f the finite vectors d Q ( γ, γ (cid:48) ) = (cid:107) v Q ( γ ) − v Q ( γ (cid:48) ) (cid:107) . The innovation of this paper is in the definition of the value v q i ( · ) and the implications around that choice.In particular in previous works [40, 41] in this framework this had been (mostly) set as the unsigned minDistfunction: v mD q ( γ ) = min p ∈ γ (cid:107) p − q (cid:107) . In this paper we alter this definition to not only capture the distanceto the shape γ , but in allowing negative values to also capture the orientation of it.This new definition leads to many interesting structural properties about shapes. These include: • When the shapes are simple curves that are closed and convex or have matching endpoints, then d Q ( γ, γ (cid:48) ) < √ d F ( γ, γ (cid:48) ) ; that is, d Q is stable up to Fr´echet perturbations. When the curves γ, γ (cid:48) arealso κ -bounded [5] then there is an interleaving: κ +1 d F ( γ, γ (cid:48) ) ≤ d ∞ Q ( γ, γ (cid:48) ) ≤ √ d F ( γ, γ (cid:48) ) where d ∞ Q uses the l ∞ distance between vector representations, or it is an equality when curves are closedand convex. Thus d Q captures orientation. In contrast for a class of curves we show d mD Q , ∞ can beequal to the Hausdorff distance, so explicitly does not capture orientation. • We introduce a new concept called the signed local feature size which captures the stability of the newsigned v i ( γ ) : R d → R at any landmark q i ∈ Ω for a fixed shape γ . Unlike its unsigned counterpart(which plays a prominent role in shape reconstruction [7, 22, 17] and computational topology [19,18, 20]), the signed local feature size for closed simple curves is infinite. This captures that whilereconstruction or medial axis properties (governed by local feature size) might be unstable on suchshapes, their signed distance function (governed by signed local feature size) is still stable. However,for curves which are not simple, it is zero. And when curves have boundary, the boundary definitionis finicky, and gives rise to nontrivial values of the signed local features size. • We show that when the signed local feature size δ is positive but finite (i.e., < δ < ∞ ) then we canset a scale parameter σ in the definition of v q (denoted v σq ) and hence in d Q (denoted as d σQ ) so thatwhen σ < δ/ (4(1 + (cid:112) ln(2 /ε )) , then the signed distance function v σi is again stable up to a value ε .Altogether, these results build and analyze a new vectorized, and sketchable distance between curves(or other geometric objects) which captures orientation like Fr´echet (or dynamic time warping, and otherpopular measures), but avoids all of the complications when actually used. As we demonstrate, fast nearestneighbor search, machine learning, clustering, etc are all now very easy. By a curve we mean the image of a continuous mapping γ : [0 , → R ; we simply use γ to refer to thesecurves. For any curve γ we correspond a direction, defined as the increasing direction of t ∈ [0 , ; that is, if t, t (cid:48) ∈ [0 , and t < t (cid:48) , then the direction of γ would be from γ ( t ) to γ ( t (cid:48) ) . Two curves γ, γ (cid:48) with differentmappings but the same images in R are in the same equivalence class if and only if they also have the samedirection. A curve is closed if γ (0) = γ (1) . It is simple if the mapping does not cross itself.Let Γ be the class of all simple curves γ in R with the property that at almost every point p on γ ,considering the direction of the curve, there is a unique normal vector n p at p , which is equivalent to theexistence of a tangent line almost everywhere on γ . Such points are called regular points of γ and the set ofregular points of γ is denoted by reg( γ ) . Points of γ \ reg( γ ) are called critical points of γ . The terminology“almost every point” means that the Lebesgue measure of those t ∈ [0 , such that γ ( t ) is a critical pointis zero. We also assume that at critical points, which are not endpoints of a non-closed curve, left and righttangent lines exist. Finally, we assume that non-closed curves in Γ have left/right tangent line at endpoints.These assumptions will guarantee the existence of a unique normal vector at critical points.2 aseline distances. Important baseline distances are the Hausdorff and Fr´echet distances. Given twocompact sets
A, B ⊂ R d , the directed Hausdorff distance is −→ d H ( A, B ) = max a ∈ A min b ∈ B (cid:107) a − b (cid:107) . Thenthe Hausdorff distance is defined d H ( A, B ) = max {−→ d H ( A, B ) , −→ d H ( B, A ) } .The Fr´echet distance is defined for curves γ, γ (cid:48) with images in R d . Let Π be the set of all monotonereparamatrizations (a non-decreasing function α from [0 , → [0 , ). It will be essential to interpret theinverse of α as interpolating continuity; that is, if a value t is a point of discontinuity for α from a to b , thenthe inverse α − should be α − ( t (cid:48) ) = t for all t (cid:48) ∈ [ a, b ] . Together, this allows α (and α − ) to representa continuous curve in [0 , × [0 , that starts at (0 , and ends at (1 , while never decreasing eithercoordinate; importantly, it can move vertically or horizontally. Then the Fr´echet distance is d F ( γ, γ (cid:48) ) = inf α ∈ Π max { sup t ∈ [0 , (cid:107) γ ( t ) − γ (cid:48) ( α ( t )) (cid:107) , sup t ∈ [0 , (cid:107) γ ( α − ( t )) − γ (cid:48) ( t ) (cid:107)} . We can similarly define the Fr´echet distance for closed oriented curves (see also [5, 44]); such a curve γ is parameterized again by arclength. Given an arbitrary point c ∈ γ , then γ ( t ) for t ∈ [0 , indicates thedistance along the curve from c in a specified direction, divided by the total arclength. Let Π ◦ denote theset of all monotone, cyclic parameterizations; now α ∈ Π ◦ is a function from [0 , → [0 , where it isnon-decreasing everywhere except for exactly one value a where α ( a ) = 0 and lim t (cid:37) a α ( t ) = 1 . Again, α − ∈ Π ◦ has the same form, and interpolates the discontinuities with segments of the constant function.Then the Fr´echet distance for oriented closed curves is defined d F ( γ, γ (cid:48) ) = inf α ∈ Π ◦ max { sup t ∈ [0 , (cid:107) γ ( t ) − γ (cid:48) ( α ( t )) (cid:107) , sup t ∈ [0 , (cid:107) γ ( α − ( t )) − γ (cid:48) ( t ) (cid:107)} . Oriented closed curves are important for modeling boundary ofshapes and levelsets [37], orientation determines inside from outside. Shape descriptors.
Given a curve γ in R , previous work identified ways it interacts with the ambientspace. The medial axis MA( γ ) [35, 8] is the set of points q ∈ R where the minimum distance min p ∈ γ (cid:107) p − q (cid:107) is not realized by a unique point p ∈ γ . The local features size [6] for a point p ∈ γ is defined lfs p ( γ ) = inf r ∈ MA( γ ) (cid:107) r − p (cid:107) is the minimum distance from p to the medial axis of γ . Definition 2.1 (Signed Local Feature Size) . Let γ ∈ Γ be a curve in R and p be a point of reg( γ ) . Define δ p = inf {(cid:107) p − p (cid:48) (cid:107) : (cid:104) n p , p − p (cid:48) (cid:105)(cid:104) n p (cid:48) , p (cid:48) − p (cid:105) < , int( pp (cid:48) ) ∩ γ = ∅ , p (cid:48) ∈ reg( γ ) } , where we assume that the infimum of the empty set is ∞ . Then we introduce the signed local feature size( slfs in short) of γ to be δ ( γ ) = inf p ∈ reg( γ ) δ p ( γ ) . Example 2.1.
Any line segment and any closed curve in Γ have infinite signed local feature size. Following the notation of signed local feature size, one can adapt the related notion of signed medial axis.For each q ∈ R and corresponding minDist point p = argmin p (cid:48) ∈ γ (cid:107) q − p (cid:48) (cid:107) on γ , we need to define anormal direction n p ( q ) at p . For regular points p ∈ reg( γ ) , this can be defined naturally by the right-handrule. For endpoints we use the normal vector of the tangent line compatible with the direction of the curve.For non-endpoint critical point, there are technical conditions for non-simple curves (see Appendix B), butin general we use the direction u which maximizes |(cid:104) u, q − p (cid:105)| with sign subject to the right-hard-rule. Definition 2.2 (Signed Medial Axis) . Let γ ∈ Γ and let q be a point in R . We say that q belongs tothe signed medial axis of γ ( SMA( γ ) in short) if there are at least two points p, p (cid:48) on γ such that p, p (cid:48) =argmin p ∈ γ (cid:107) q − p (cid:107) and (cid:104) n p ( q ) , p − p (cid:48) (cid:105)(cid:104) n p (cid:48) ( q ) , p (cid:48) − p (cid:105) < . The signed medial axis of a curve is a subset of its usual medial axis. Also, if slfs( γ ) = ∞ , then γ has nosigned medial axis, i.e. SMA( γ ) = ∅ . 3 efinition 2.3 (Feature Mapping) . Let γ be a curve, Q be a finite subset of R and σ > . For each q ∈ Q let p = argmin p (cid:48) ∈ γ (cid:107) q − p (cid:48) (cid:107) . If p is not an endpoint of γ , we define v σq ( γ ) = 1 σ (cid:104) n p ( q ) , q − p (cid:105) e − (cid:107) q − p (cid:107) σ . Otherwise (for endpoints) we set v σq ( γ ) = 1 σ (cid:104) n p , q − p (cid:107) q − p (cid:107) (cid:105)(cid:107) q (cid:107) ∞ ,p e (cid:107) q − p (cid:107) σ , where (cid:107) q (cid:107) ∞ ,p is the l ∞ -norm of q in the coordinate system with axis parallel to n p and L (tangent line at p ) and origin at p ; see Figure 1(right) for an illustration. See an example of v σq over R in Figure 1(left).Notice that (cid:107) q (cid:107) ,p = (cid:107) q − p (cid:107) and so √ ≤ (cid:107) q (cid:107) ∞ ,p (cid:107) q − p (cid:107) ≤ . If Q = { q , q , . . . , q n } , setting v σi ( γ ) = v σq i ( γ ) we obtain a feature mapping v σQ : Γ → R n defined by v σQ ( γ ) = ( v σ ( γ ) , · · · , v σn ( γ )) . (We will drop thesuperscript σ afterwards, unless otherwise specified.) L n p qγ y xp Figure 1: Left: Example signed distance function v q for curve. Right: Definition of v q at endpoints. Definition 2.4 (Orientation Preserving Distance) . Let γ , γ ∈ Γ be two curves in R , Q = { q , q , . . . , q n } be a point set in R , σ > be a positive constant and p ∈ [1 , ∞ ] . The orientation preserving distance of γ and γ , associated with Q , σ and p , denoted d σ,pQ ( γ , γ ) , is the normalized l p -Euclidean distance of two n -dimensional feature vectors v Q ( γ ) and v Q ( γ ) in R n , i.e. for p ∈ [1 , ∞ ) , d σ,pQ ( γ , γ ) = 1 √ n (cid:107) v Q ( γ ) − v Q ( γ ) (cid:107) p = (cid:18) n n (cid:88) i =1 | v i ( γ ) − v i ( γ ) | p (cid:19) /p , and for p = ∞ , d σ, ∞ Q ( γ , γ ) = (cid:107) v Q ( γ ) − v Q ( γ ) (cid:107) ∞ = max ≤ i ≤ n | v i ( γ ) − v i ( γ ) | . As default we use d σQ instead of d σ, Q . Landmarks Q can be described by a probability distribution µ : R → R , then v Q is infinite-dimensional, and we can define d σ,pQ ( γ , γ ) = ( (cid:82) q ∈ R | v q ( γ ) − v q ( γ ) | p µ ( q )) /p , and d σ, ∞ Q ( γ , γ ) = sup q ∈ R µ | v q ( γ ) − v q ( γ ) | where R µ = { x ∈ R | µ ( x ) > } . Since we employ a feature map to embed curves into a Euclidean space and then the usual l p -norm todefine the distance between two curves, the function d σ,pQ enjoys all properties of a metric but the definitenessproperty. That is, it satisfies triangle inequality, is symmetric, and d σ,pQ ( γ , γ ) = 0 provided γ = γ (i.e.4 and γ have a same range and a same direction). However, d σ,pQ ( γ , γ ) = 0 does not necessarily imply γ = γ : consider two curves which overlap, and all landmarks have closest points on the overlap.To address this problem, following Phillips and Tang [40], we can restrict the family of curves to be τ -separated (they are piecwise-linear and critical points are a distance of at least τ to non-adjecent parts of thecurve), and assume the landmark set is sufficiently dense (e.g., a grid with separation ≤ τ / ). Under theseconditions again d σ,pQ is definite, and is a metric. d σ,pQ Now we proceed to the stability properties of the distance d σ,pQ . Our first goal is to show that d σQ is stableunder perturbations of Q , which is given in two Theorems 3.1 and 3.2. The next is to verify its stabilityunder perturbations of curves (see Theorem 3.3, and its several corollaries). Q Before stating stability properties under perturbations of landmarks, we discuss some cases that will notsatisfy in the desired inequality and we have to exclude these cases. The first case is when
SMA( γ ) = ∅ and two landmarks q and q are in different sides of the medial axis of γ and at least one of them choosesan endpoint as argmin point (see Figure 2(a)). The other case is when SMA( γ ) is nonempty, q and q arein different sides of SMA( γ ) and at least one of them chooses an endpoint as argmin point and is along thetangent of that endpoint (see Figure 2(b)). In both cases, q can be arbitrarily close to q but | v ( γ ) − v ( γ ) | is likely to be roughly / √ e since v q ( γ ) = 0 . For instance, in Figure 2(a), | v ( γ ) − v ( γ ) | = | v ( γ ) | = σ (cid:107) q − p (cid:107) e −(cid:107) q − p (cid:107) σ , which can be as close as / √ e when (cid:107) q − p (cid:107) is about σ/ √ . γ γ q q p p n p n p MA n p n p SMA q q ( a ) ( b ) p p Figure 2: The cases that q and q choose different endpoints of γ as argmin points Theorem 3.1 (Landmark stability I) . Let γ ∈ Γ and q , q be two points in R . If δ ( γ ) = ∞ and q and q do not satisfy the above first case (e.g., γ is a closed curve), then | v ( γ ) − v ( γ ) | ≤ σ (cid:107) q − q (cid:107) .Proof. Let p = argmin p ∈ γ (cid:107) q − p (cid:107) and p = argmin p ∈ γ (cid:107) q − p (cid:107) . We prove the theorem in four cases. Case 1. v ( γ ) v ( γ ) ≤ , the line segment q q passes through γ and p and p are not endpoints (see Figure3(a)). Let p be the intersection of the segment q q with γ . Then | v ( γ ) − v ( γ ) | = (cid:12)(cid:12)(cid:12)(cid:12) σ (cid:104) q − p , n p ( q ) (cid:105) e − (cid:107) q − p (cid:107) σ − σ (cid:104) q − p , n p ( q ) (cid:105) e − (cid:107) q − p (cid:107) σ (cid:12)(cid:12)(cid:12)(cid:12) ≤ σ (cid:107) q − p (cid:107) e − (cid:107) q − p (cid:107) σ + σ (cid:107) q − p (cid:107) e − (cid:107) q − p (cid:107) σ ≤ σ ( (cid:107) q − p (cid:107) + (cid:107) q − p (cid:107) ) ≤ σ ( (cid:107) q − p (cid:107) + (cid:107) q − p (cid:107) ) = σ (cid:107) q − q (cid:107) . ase 2. v ( γ ) v ( γ ) ≥ , the line segment q q does not pass through γ and p and p are not endpoints (seeFigure 3(b)). Without loss of generality we may assume that both v ( γ ) and v ( γ ) are non-negative. In thiscase, q − p and q − p are parallel to n p ( q ) and n p ( q ) respectively. Therefore, (cid:104) q − p , n p ( q ) (cid:105) = (cid:107) q − p (cid:107) and (cid:104) q − p , n p ( q ) (cid:105) = (cid:107) q − p (cid:107) . Utilizing the fact that the function f ( x ) = xσ e − x /σ isLipschitz with constant σ , we get | v ( γ ) − v ( γ ) | ≤ σ |(cid:107) q − p (cid:107) − (cid:107) q − p (cid:107)| . Now applying triangle inequality we infer (cid:107) q − p (cid:107) ≤ (cid:107) q − p (cid:107) ≤ (cid:107) q − q (cid:107) + (cid:107) q − p (cid:107) and so bysymmetry, |(cid:107) q − p (cid:107) − (cid:107) q − p (cid:107)| ≤ (cid:107) q − q (cid:107) . Therefore, | v ( γ ) − v ( γ ) | ≤ σ (cid:107) q − q (cid:107) . Case 3.
Endpoints. Let (cid:96) be the tangent line at an endpoint p on γ , n p be its unique unit normal vectorand let q and q be in different sides of (cid:96) and p = p = p (see Figure 3(c)). Assume q is the intersectionof the segment q q with (cid:96) . Then (cid:104) n p , q − p (cid:105) = 0 and so noting that n p ( q ) = n p ( q ) = n p we have (cid:104) q − p, n p (cid:105) = (cid:104) q − q, n p (cid:105) and (cid:104) q − p, n p (cid:105) = (cid:104) q − q, n p (cid:105) . Therefore, | v ( γ ) − v ( γ ) | = (cid:12)(cid:12)(cid:12)(cid:12) σ (cid:104) n p , q − p (cid:107) q − p (cid:107) (cid:105)(cid:107) q (cid:107) ∞ ,p e (cid:107) q − p (cid:107) σ − σ (cid:104) n p , q − p (cid:107) q − p (cid:107) (cid:105)(cid:107) q (cid:107) ∞ ,p e (cid:107) q − p (cid:107) σ (cid:12)(cid:12)(cid:12)(cid:12) = σ (cid:12)(cid:12)(cid:12)(cid:12)(cid:68) n p , (cid:107) q (cid:107) ∞ ,p (cid:107) q (cid:107) ,p e − (cid:107) q − p (cid:107) σ ( q − q ) − (cid:107) q (cid:107) ∞ ,p (cid:107) q (cid:107) ,p e − (cid:107) q − p (cid:107) σ ( q − q ) (cid:69)(cid:12)(cid:12)(cid:12)(cid:12) = σ (cid:13)(cid:13)(cid:13)(cid:13) (cid:107) q (cid:107) ∞ ,p (cid:107) q (cid:107) ,p e − (cid:107) q − p (cid:107) σ ( q − q ) − (cid:107) q (cid:107) ∞ ,p (cid:107) q (cid:107) ,p e − (cid:107) q − p (cid:107) σ ( q − q ) (cid:13)(cid:13)(cid:13)(cid:13) ≤ σ ( (cid:107) q − q (cid:107) + (cid:107) q − q (cid:107) ) = σ (cid:107) q − q (cid:107) . If q and q are in one side of (cid:96) and p = p = p , the proof is the same as in Case 2. We only need to applyCauchy-Schwarz inequality. Case 4.
The case where p is an endpoint but p is not can be gained from a combination of above cases.Basically, choose a point q on the line segment q q so that q − p is parallel to n p and then use the triangleinequality. p (cid:96)γ q q p p (cid:96) (cid:96) γq q q q pγ ( a ) ( b ) ( c ) Figure 3: q and q in different cases Theorem 3.2 (Landmark stability II) . Let γ ∈ Γ and q , q be two points in R not satisfying the secondcase mentioned before Theorem 3.1. If δ ( γ ) < ∞ , (cid:15) ≤ δ ( γ )4 is an arbitrary positive real number and σ ≤ δ ( γ ) / (4(1 + (cid:112) ln(2 /(cid:15) ))) , then | v ( γ ) − v ( γ ) | ≤ max { (cid:15), σ (cid:107) q − q (cid:107)} .Proof. By Theorem 3.1 it is enough to consider only the case where there is a signed medial axes, say M ,and q and q are in different sides of M (the case they are in same side of M is included in Theorem3.1). We handle the proof in two various cases. For the sake of convenience assume x = (cid:107) q − p (cid:107) and y = (cid:107) q − p (cid:107) . The proof is based on the following observations. (O1) Since (cid:107) p − q (cid:107) ≤ (cid:107) p − q (cid:107) , we get x + (cid:15) ≥ (cid:107) p − p (cid:107) ≥ δ ( γ )2 ≥ σ (1 + (cid:112) ln(2 /(cid:15) )) . So applying (cid:15) ≤ δ ( γ )4 we gain x ≥ δ ( γ )4 ≥ σ (1 + (cid:112) ln(2 /(cid:15) )) . 6 p q q p p +++ −−− SMA n p δ/ δ/ δ δγ n p n p (cid:48) q SMA( γ (cid:48) ) γ (cid:48) γ SMA( γ ) Figure 4: Left: The case that a landmark point q lies between SMA( γ ) and SMA( γ (cid:48) ) . Right: The case thatthere is a SMA and q and q in different sides of SMA( γ ) (O2) Similarly, we obtain y ≥ δ ( γ )4 ≥ σ (1 + (cid:112) ln(2 /(cid:15) )) . (O3) Employing the inequality xσ e − x σ ≤ e xσ − e − x σ = e − ( xσ − and (O1) we get xσ e − x σ ≤ (cid:15) . (O4) Similarly, we earn yσ e − y σ ≤ (cid:15) .If (cid:107) q − q (cid:107) ≤ (cid:15) , then (cid:15) ≤ δ ( γ )4 implies | v ( γ ) − v ( γ ) | = xσ e − x σ + yσ e − y σ ≤ (cid:15) . Otherwise, (cid:107) q − q (cid:107) ≥ (cid:15) and we encounter four cases (see Figure 4(left)). Case 1. If x, y < δ ( γ )4 , then | v ( γ ) − v ( γ ) | = xσ e − x σ + yσ e − y σ ≤ xσ + yσ ≤ δ ( γ )4 σ + δ ( γ )4 σ ≤ σ (cid:107) q − q (cid:107) . Case 2. If x ≥ δ ( γ )4 and y < δ ( γ )4 , then applying (O3) we infer | v ( γ ) − v ( γ ) | = xσ e − x σ + yσ e − y σ ≤ (cid:15) + δ ( γ )4 σ ≤ (cid:16) (cid:113) ln( (cid:15) ) (cid:17) + δ ( γ )4 σ ≤ δ ( γ )2 σ ≤ σ (cid:107) q − q (cid:107) . Case 3.
The case x < δ ( γ )4 and y ≥ δ ( γ )4 is the same as Case 2. Case 4.
Finally, if x ≥ δ ( γ )4 and y ≥ δ ( γ )4 , by (O3) and (O4), | v ( γ ) − v ( γ ) | = xσ e − x σ + yσ e − y σ ≤ (cid:15) . We next show stability properties of d Q under perturbation of curves; we do this in the context of otherdistances, namely the Fr´echet and Hausdorff distances. Specifically, we show if two curves are close underanother distance, e.g., Fr´echet, then they must also be close under d Q , under some conditions.Moreover, non-closed curves create subtle issues around endpoints. The example in Figure 4(right) showsthat, without controlling behavior of endpoints, we may make γ arbitrarily close to γ (cid:48) in Fr´echet distance,whereas d σQ ( γ, γ (cid:48) ) is possibly / √ e , where Q = { q } . This is the case where q lies between SMA( γ ) and SMA( γ (cid:48) ) . So we cannot get the desired inequality ( d σQ ( γ, γ (cid:48) ) ≤ d F ( γ, γ (cid:48) ) ) for this case.Thus, the landmarks which fall between the signed medial axes may cause otherwise similar curves tohave different signatures. For a large domain Ω (and especailly with σ , relatively small) these should berare, and then d σQ which averages over these landmarks should not be majorly effected. We formalize whenthis is the case in the next theorem, and its corollaries. Theorem 3.3 (Stability under Fr´echet perturbation of curves) . Let γ, γ (cid:48) ∈ Γ and q i ∈ R . If one of thefollowing three conditions hold, then | v i ( γ ) − v i ( γ (cid:48) ) | ≤ σ d F ( γ, γ (cid:48) ) .(1) v i ( γ ) v i ( γ (cid:48) ) ≥ ;(2) v i ( γ ) v i ( γ (cid:48) ) ≤ and q i is on a line segment γ ( t ) γ (cid:48) ( α ( t )) of the alignment between γ and γ (cid:48) achievingthe optimal Fr´echet distance;(3) q i is far enough from both curves: min p ∈ γ (cid:107) q i − p (cid:107) , min p (cid:48) ∈ γ (cid:48) (cid:107) q i − p (cid:48) (cid:107) ≥ σ (1 + (cid:112) ln(2 σ/ d F ( γ, γ (cid:48) ))) . roof. Let p = argmin p ∈ γ (cid:107) q i − p (cid:107) and p (cid:48) = argmin p ∈ γ (cid:48) (cid:107) q i − p (cid:107) .(1) Let p = γ ( t ) and p (cid:48) = γ ( t (cid:48) ) for some t, t (cid:48) ∈ [0 , and without loss of generality assume that t ≤ t (cid:48) .Then (cid:107) q i − p (cid:48) (cid:107) ≤ (cid:107) q i − γ (cid:48) ( t ) (cid:107) and so (cid:107) q i − p (cid:48) (cid:107) − (cid:107) q i − p (cid:107) ≤ (cid:107) q i − γ (cid:48) ( t ) (cid:107) − (cid:107) q i − p (cid:107) ≤ (cid:107) p − γ (cid:48) ( t ) (cid:107) = (cid:107) γ ( t ) − γ (cid:48) ( t ) (cid:107) ≤ (cid:107) γ − γ (cid:48) (cid:107) ∞ . Similarly, (cid:107) q i − p (cid:107) − (cid:107) q i − p (cid:48) (cid:107) ≤ (cid:107) γ − γ (cid:48) (cid:107) ∞ . Now using the fact that the function f ( x ) = xσ e − x σ isLipschitz, considering l ∞ -norm at endpoints, we get | v i ( γ ) − v i ( γ (cid:48) ) | ≤ σ |(cid:107) q i − p (cid:48) (cid:107) − (cid:107) q i − p (cid:107)| ≤ σ (cid:107) γ − γ (cid:48) (cid:107) ∞ . This shows that for two arbitrary reparametrizations α and α (cid:48) of [0 , we have | v i ( γ ◦ α ) − v i ( γ (cid:48) ◦ α (cid:48) ) | ≤ σ (cid:107) γ ◦ α − γ (cid:48) ◦ α (cid:48) (cid:107) ∞ . Noting that a reparametrization of a curve does not change either the range or thedirection of the curve, we get | v i ( γ ◦ α ) − v i ( γ (cid:48) ◦ α (cid:48) ) | = | v i ( γ ) − v i ( γ (cid:48) ) | . Thus taking the infimum over allreparametrizations α and α (cid:48) we obtain | v i ( γ ) − v i ( γ (cid:48) ) | ≤ σ d F ( γ, γ (cid:48) ) .(2) Let r = d F ( γ, γ (cid:48) ) and let q i be on a line segment alignment of γ, γ (cid:48) with length at most r . So, thereare points a and b on γ and γ (cid:48) respectively within distance r such that q i lies on the line segment ab . Hencewe have (cid:107) p − q i (cid:107) + (cid:107) q i − p (cid:48) (cid:107) ≤ (cid:107) a − q i (cid:107) + (cid:107) b − q i (cid:107) = (cid:107) a − b (cid:107) ≤ r = d F ( γ, γ (cid:48) ) , so | v i ( γ ) − v i ( γ (cid:48) ) | ≤ σ ( (cid:107) p − q i (cid:107) + (cid:107) q i − p (cid:48) (cid:107) ) ≤ σ d F ( γ, γ (cid:48) ) . (3) This case implies | v i ( γ ) | , | v i ( γ (cid:48) ) | ≤ σ d F ( γ, γ (cid:48) ) . Corollary 3.4.
Let γ, γ (cid:48) ∈ Γ with the same endpoints, and also the same tangent at each end point. Then d σQ ( γ, γ (cid:48) ) ≤ σ d F ( γ, γ (cid:48) ) .Proof. Let q i ∈ Q . If q i is not in the area between γ and γ (cid:48) , then it satisfies Condition (1) of Theorem3.3. Otherwise, we claim that q i must lie on a line segment γ ( t ) γ (cid:48) ( α ( t )) induced by reparametrization α achieving the optimal Fr´echet distance, and thus will satisfy Condition (2) of Theorem 3.3.Let ´ α describe a reparametrization mapping from γ to γ (cid:48) as a non-decreasing, continuous path in the [0 , × [0 , parameter space. It defines a homotopy from γ to γ (cid:48) , and each t ∈ [0 , defines the point oneither curve corresponding to a t -fraction of the arclength along this path. We can instantiate this homotopyas a flow f , the continuous transformation of γ to γ (cid:48) parametrized by a value s ∈ [0 , , so f (0) = γ and f (1) = γ (cid:48) , and any value in between f ( s ) is also a curve with image in R . In particular each point on suchcurve is still parametrized by t ∈ [0 , where f ( s )( t ) = (1 − s ) γ ( t ) + sγ (cid:48) ( t ) . Each point q i in between thecurves must be included as some intermediate point f ( s )( t ) ; if not then it would mean that the two curvesare not homotopic, however they are both both simple curves sharing endpoints [32][Proposition 1.2]. Thus,it implies that q i is on the segment between γ ( ´ α ( t )) and γ (cid:48) ( ´ α ( t )) , and must satisfy condition (2). Corollary 3.5.
Let γ, γ (cid:48) ∈ Γ be closed curves with both oriented clockwise/counterclockwise. Then d σQ ( γ, γ (cid:48) ) ≤ σ d F ( γ, γ (cid:48) ) .Proof. Using Condition (1) of Theorem 3.3, it is enough to show that if q ∈ A \ A (cid:48) , then | v q ( γ ) − v q ( γ (cid:48) ) | ≤ σ d F ( γ, γ (cid:48) ) , where A, A (cid:48) , by Jordan’s curve theorem, are the regions bounded by γ, γ (cid:48) respectively. Thecase q ∈ A (cid:48) \ A comes by symmetry. We claim that q lies on a line segment of the alignment between γ and γ (cid:48) achieving the optimal Fr ´e chet distance. Then the statement of the theorem follows by Theorem 3.3 as itsCondition (2) will hold true.Assume to the contrary that q does not lie on such a line segment. Now consider γ and γ (cid:48) in R \ { q } andlet x be a point in R \ { q } . Using the fact that in path-connected topological spaces, like R \ { q } , up to8somorphism of groups the fundamental group of the space is independent of the choice of base point x ,we see that in R \ { q } , γ (cid:48) is contractible (i.e. homotopic to x ) but γ is homotopic to S , the unit circle.It means that there cannot be a homotopy between γ and γ (cid:48) since the homotopy relation is an equivalencerelation and S is not contractible, as their fundamental groups are not isomorphic.On the other hand, let r = d F ( γ, γ (cid:48) ) and let α be a reparametrization achieving the optimal alignment forFr ´e chet distance. It means that the mapping F : [0 , × [0 , → R defined by F ( s, t ) = s ( γ ◦ α )( t ) +(1 − s ) γ (cid:48) ( t ) is a straight line homotopy between γ ◦ α and γ (cid:48) , and by assumption on q we know that thishomotopy occurs in R \ { q } . Since reparametrizations do not change the homotopy class of curves, weobserve that there is a homotopy between γ and γ (cid:48) in R \ { q } , which is a contradiction. l ∞ Variants
Using the l ∞ variants, we can show a stronger interleaving property. Let Ω be a bounded domain in R .Let diam(Ω) = sup x,y ∈ Ω (cid:107) x − y (cid:107) be the diameter of Ω . We also denote by Γ Ω the subset of Γ containingall curves with image in Ω . In Appendix A we show if γ, γ (cid:48) ∈ Γ Ω and Q is uniform on a domain Ω ,then d H ( γ, γ (cid:48) ) = d mD Q , ∞ ( γ, γ (cid:48) ) . The signed variant d ∞ Q is more related to d F , but it is difficult to show aninterleaving result in general because if a curve cycles around multiple times, its image may not significantlychange, but its Fr´echet distance does. However, by appealing to a connection to the Hausdorff distance, andthen restricting to closed and convex or κ -bounded [5] curves, we can still achieve an interleaving bound.We first focus on closed curves, so slfs is infinite, and there are no boundary issues; thus it is best toset σ sufficiently large so the exp( −(cid:107) p − q (cid:107) /σ ) term in v q goes to and can be ignored. Regardless, d σQ ≤ / √ e . Note that v q and hence d Q has a σ factor, so those terms in the expressions cancel out. Lemma 3.1.
Assume that Q is a uniform measure on Ω and σ is sufficiently large. Let γ, γ (cid:48) ∈ Γ Ω be twoclosed curves such that d H ( γ, γ (cid:48) ) ≤ σ √ e . Then σ d H ( γ, γ (cid:48) ) ≤ d σ, ∞ Q ( γ, γ (cid:48) ) .Proof. Let r = d H ( γ, γ (cid:48) ) . Without loss of generality we can assume that r = sup p ∈ γ inf p (cid:48) ∈ γ (cid:48) (cid:107) p − p (cid:48) (cid:107) .Since the range of γ is compact (the image of a compact set under a continuous map is compact), there is p ∈ γ such that r = min p (cid:48) ∈ γ (cid:48) (cid:107) p − p (cid:48) (cid:107) . Similarly, by the continuity of the range of γ (cid:48) we conclude that thereis p (cid:48) ∈ γ such that r = (cid:107) p − p (cid:48) (cid:107) . Because Q is dense in Ω then p ∈ Q . Since p (cid:48) = argmin p (cid:48)(cid:48) ∈ γ (cid:48) (cid:107) p − p (cid:48)(cid:48) (cid:107) ,we observe that v p ( γ (cid:48) ) = σ (cid:107) p − p (cid:48) (cid:107) = rσ . On the other hand, v p ( γ ) = 0 as p ∈ γ . Therefore, at least oneof the components of the sketched vector v Q ( γ (cid:48) ) − v Q ( γ ) is rσ and so σd σ, ∞ Q ( γ, γ (cid:48) ) ≥ r . Corollary 3.6.
Assume Q is a uniform measure on Ω and σ is sufficiently large. Let γ, γ (cid:48) ∈ Γ Ω be twoclosed curves. Then d H ( γ, γ (cid:48) ) ≤ √ e diam(Ω) d σ, ∞ Q ( γ, γ (cid:48) ) . Corollary 3.7.
Let Q be a uniform measure on Ω and σ be sufficiently large. Let γ, γ (cid:48) ∈ Γ Ω be two closedconvex curves with both oriented clockwise/counterclockwise and d H ( γ, γ (cid:48) ) ≤ σ √ e . Then d σ, ∞ Q ( γ, γ (cid:48) ) = σ d F ( γ, γ (cid:48) ) .Proof. Applying Lemma 3.1 and the p = ∞ version of Corollary 3.5 we get σ d H ( γ, γ (cid:48) ) ≤ d σ, ∞ Q ( γ, γ (cid:48) ) ≤ σ d F ( γ, γ (cid:48) ) . Now by Theorem 1 of [5] we know that the Hausdorff and Fr ´e chet distances coincide for closedconvex curves. Therefore, d H ( γ, γ (cid:48) ) = d F ( γ, γ (cid:48) ) and the proof is complete.The proof of Lemma 3.1 shows that the inequality σ d H ( γ, γ (cid:48) ) ≤ d σ, ∞ Q ( γ, γ (cid:48) ) remains valid for non-closedcurves γ and γ (cid:48) as long as p (cid:48) in the proof is not an endpoint of γ (cid:48) . A piecewise linear curve γ in R is called κ -bounded [5] for some constant κ ≥ if for any t, t (cid:48) ∈ [0 , with t < t (cid:48) , p = γ ( t ) , p (cid:48) = γ ( t (cid:48) ) we have γ ([ t, t (cid:48) ]) ⊆ B r ( p ) ∪ B r ( p (cid:48) ) , where r = κ (cid:107) p − p (cid:48) (cid:107) . The class of κ -bounded curves comprises of κ -straightcurves [5], curves with increasing chords [43] and self-approaching curves [2].9 orollary 3.8. Let Q be a uniform measure on Ω and σ be sufficiently large. Let γ (cid:48) , γ ∈ Γ Ω with the sameendpoints and with the same tangents at endpoints, and both κ -bounded, with d H ( γ, γ (cid:48) ) ≤ σ √ e . Then σ ( κ + 1) d F ( γ, γ (cid:48) ) ≤ d σ, ∞ Q ( γ, γ (cid:48) ) ≤ σ d F ( γ, γ (cid:48) ) . Proof.
The p = ∞ version of Corollary 3.4 provides the second inequality. Using Lemma 3.1 we have d H ( γ, γ (cid:48) ) ≤ σ d σ, ∞ Q ( γ, γ (cid:48) ) . Now, since γ and γ (cid:48) are κ -bounded, by Theorem 2 of [5] we have d F ( γ, γ (cid:48) ) ≤ ( κ + 1) d H ( γ, γ (cid:48) ) . Combining these inequalities we get the desired result. d σQ Distance
Like with recent vectorized distance d mD Q [40, 41], this structure allows for very simple and powerful dataanalysis. Nearest neighbor search can use heavily optimized libraries [3, 42]. Clustering can use Lloyd’salgorithm for k -means clustering. And we can directly use many built in classification methods. Beijing driver classification.
We first recreate the main classification experiment from Phillips andTang [40] on the Geolife GPS trajectory dataset [49]. After pruning to 128 users, each with between 20and 200 trajectories, we train a classifier on each pair of users. We repeat on each pair 10 times with dif-ferent test/train splits, and report the average misclassification rate under various methods, now includingon the new vectors v Q ( γ ) for each curve, using σ = 0 . from a domain [0 , . The results with linearSVM, Gaussian SVM (hyperparameters C = 2 and γ = 0 . ), polynomial kernel SVM, decision tree, andrandom forest (hyperparameters to “auto”) are shown in Table 1. While v mD Q (with an error rate of . with random forest) outperforms v σQ (error rate of . with random forest), other distances can only useKNN classifiers. v σQ performs slightly worse than DTW, Eu, d H , LCSS and EDR (in range . to . ;see Table 1 in [40]), but better than discrete Fr´echet and LSH approximations of it (in range . to . ). Directional synthetic dataset classification.
Second, we create a synthetic data set for which thedirection information is essential. We generate trajectories so start from a square A = [ − , × [ − , and end in another rectangle B = [98 , × [ − , . The other half start in B and end in A . Each isalso given other critical points, the i th in rectangle [ i, i + 1] × [ − , (or reverse order for B to A ). Wetry to classify the first half (A to B) from the second half (B to A). We repeat 1000 balanced 70/30 train/testsplits and report the classification test error in Table 1. Now, while v mD Q never achieves better than . errorrate (not much better than random), with all classifiers we achieve close to an error rate of using v σQ . UsingKNN classifiers, dynamic time warping, and Fr´echet can also achieve near- error rates. Distance v σQ v mD Q Classifier Mean Median Variance Mean Median Variance B e iji ng Linear kernel SVM 0.2741 0.2625 0.0201 0.1766 0.1429 0.0173Gaussian kernel SVM 0.2167 0.2000 0.0148 0.1849 0.1549 0.0183Poly kernel SVM, deg=auto 0.2800 0.2716 0.0183 0.2402 0.2281 0.0182Decision Tree 0.1496 0.1250 0.0110 0.0739 0.0562 0.0060RandomForest with 100 estimators 0.1173 0.0926 0.0096 0.0603 0.0426 0.0051 D i r ec ti on a l Linear SVM 0.0012 0.0000 0.0000 0.4900 0.4833 0.0030Gaussian kernel SVM 0.0005 0.0000 0.0000 0.4360 0.4333 0.0031SVM, poly, deg= auto 0.0004 0.0000 0.0000 0.4670 0.4667 0.0031Decision Tree 0.0287 0.0167 0.0006 0.4827 0.4833 0.0037LogisticRegression 0.0000 0.0000 0.0000 0.4866 0.4833 0.0031Table 1: Test errors with v σQ and v mD Q vectorizations.10 eferences [1] Pankaj K. Agarwal, Rinat Ben Avraham, Haim Kaplan, and Micha Sharir. Computing the discretefrechet distance in subquadratic time. Siam Journal of Computing , 43:429–449, 2014.[2] O. Aichholzer, F. Aurenhammer, C. Icking, R. Klein, E. Langetepe, and G. Rote. Generalized self-approaching curves.
Discrete Appl. Math. , 109:3–24, 2001.[3] Ann Arbor Algorithms. K-graph. Technical report, https://github.com/aaalgo/kgraph ,2018.[4] Helmut Alt and Michael Godau. Computing the fr´echet distance between two polygonal curves.
JCGAppl. , 5:75–91, 1995.[5] Helmut Alt, Christian Knauer, and Carola Wenk. Comparison of distance measures for planar curves.
Algorithmica , 2004.[6] Nina Amenta and Marshall Bern. Surface reconstruction by voronoi filtering.
Discrete & Computa-tional Geometry , 22(4):481–504, 1999.[7] Nina Amenta, Sunghee Choi, and Ravi Krishna Kolluri. The power crust. In
Proceedings of the sixthACM symposium on Solid modeling and applications , 2001.[8] Nina Amenta, Sunghee Choi, and Ravi Krishna Kolluri. The power crust, unions of balls, and themedial axis transform.
Computational Geometry , 19(2-3):127–153, 2001.[9] Arturs Backurs and Piotr Indyk. Edit distance cannot be computed in strongly subquadratic time (un-less seth is false). In
Proceedings of the forty-seventh annual ACM symposium on Theory of computing ,pages 51–58, 2015.[10] Julian Baldus and Karl Bringmann. A fast implementation of near neighbors queries for fr´echet dis-tance (gis cup). In
Proceedings of the 25th ACM SIGSPATIAL International Conference on Advancesin Geographic Information Systems , 2017.[11] Karl Bringmann. Why walking the dog takes time: Frechet distance has no strongly subquadraticalgorithms unless SETH fails. In
FOCS , 2014.[12] Karl Bringmann and Marvin K¨unnemann. Quadratic conditional lower bounds for string problems anddynamic time warping. In
FOCS , 2015.[13] Karl Bringmann, Marvin K¨unnemann, and Andr´e Nusser. Walking the dog fast in practice: Algorithmengineering of the frechet distance. In
International Symposium on Computational Geometry , 2019.[14] Kevin Buchin, Maike Buchin, Wouter Meulemans, and Wolfgang Mulzer. Four soviets walk the dog:Improved bounds for computing the fr´echet distance.
Discrete & Computational Geometry , 58(1):180–216, 2017.[15] Kevin Buchin, Yago Diez, Tom van Diggelen, and Wouter Meulemans. Efficient trajectory queriesunder the fr´echet distance (gis cup). In
Proceedings of the 25th ACM SIGSPATIAL InternationalConference on Advances in Geographic Information Systems , 2017.[16] Kevin Buchin, Anne Driemel, Natasja van de L’Isle, and Andr´e Nusser. klcluster: Center-based clus-tering of trajectories. In
Proceedings of the 27th ACM SIGSPATIAL International Conference onAdvances in Geographic Information Systems , pages 496–499, 2019.1117] Fr´ed´eric Chazal and David Cohen-Steiner. Geometric inference.
Tessellations in the Sciences , 2012.[18] Fr´ed´eric Chazal, David Cohen-Steiner, and Quentin M´erigot. Geometric inference for probabilitymeasures.
Foundations of Computational Mathematics , 11(6):733–751, 2011.[19] Fr´ed´eric Chazal, Brittany Terese Fasy, Fabrizio Lecci, Bertrand Michel, Alessandro Rinaldo, and LarryWasserman. Robust topolical inference: Distance-to-a-measure and kernel distance. Technical report,arXiv:1412.7197, 2014.[20] Fr´ed´eric Chazal and Andre Lieutier. The “ λ -medial axis”. Graphical Models , 67:304–331, 2005.[21] Lei Chen, M. Tamer ¨Ozsu, and Vincent Oria. Robust and fast similarity search for moving objecttrajectories. In
SIGMOD , pages 491–502, 2005.[22] Siu-Wing Cheng, Tamal K Dey, and Jonathan Shewchuk.
Delaunay mesh generation . CRC Press,2012.[23] Michael O. Cruz, Hendrik Macedo, R. Barreto, and Adolfo Guimaraes.
GPS Trajectories Data Set ,February 2016.[24] Mark de Berg, Atlas F. Cook IV, and Joachim Gudmundsson. Fast frechet queries. In
Symposium onAlgorithms and Computation , 2011.[25] Anne Driemel, Sariel Har-Peled, and Carola Wenk. Approximating the fr´echet distance for realisticcurves in near linear time.
Discrete & Computational Geometry , 48(1):94–127, 2012.[26] Anne Driemel, Amer Krivosija, and Christian Sohler. Clustering time series under the Frechet distance.In
ACM-SIAM Symposium on Discrete Algorithms , 2016.[27] Anne Driemel, Ioannis Psarros, and Melanie Schmidt. Sublinear data structures for short frechetqueries. Technical report, arXiv:1907.04420, 2019.[28] Anne Driemel and Francesco Silvestri. Locality-sensitive hashing of curves. In , 2017.[29] Fabian D¨utsch and Jan Vahrenhold. A filter-and-refinement-algorithm for range queries based on thefr´echet distance (gis cup). In
Proceedings of the 25th ACM SIGSPATIAL International Conference onAdvances in Geographic Information Systems , pages 1–4, 2017.[30] Thomas Eiter and Heikki Mannila. Computing discrete Frechet distance. Technical report, ChristianDoppler Laboratory for Expert Systems, 1994.[31] Arnold Filtser, Omrit Filtser, and Matthew J. Katz. Approximate nearest neighbor for curves — simple,efficient, and deterministic. In
ICALP , 2020.[32] Allen Hatcher.
Algebraic topology . Cambridge University Press, 2005.[33] Piotr Indyk. On approximate nearest neighbors in non-euclidean spaces. In
Proceedings 39th AnnualSymposium on Foundations of Computer Science (Cat. No. 98CB36280) , pages 148–155. IEEE, 1998.[34] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convo-lutional neural networks. In
Advances in neural information processing systems , pages 1097–1105,2012. 1235] Der-Tsai Lee. Medial axis transformation of a planar shape.
IEEE Transactions on pattern analysisand machine intelligence , 4(4):363–369, 1982.[36] Daniel Lemire. Faster retrieval with a two-pass dynamic-time-warping lower bound.
Pattern recogni-tion , 42(9):2169–2180, 2009.[37] William E. Lorensen and Harvey E. Cline. Marching cubes: A high resolution 3d surface constructionalgorithm.
ACM SIGGRAPH Computer Graphics , 21:163–169, 1987.[38] Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg Corrado, and Jeffrey Dean. Distributed representationsof words and phrases and their compositionality. In
NeurIPS , 2013.[39] Jeffrey Pennington, Richard Socher, and Christopher D. Manning. Glove: Global vectors for wordrepresentation. In
EMNLP , 2014.[40] Jeff M. Phillips and Pingfan Tang. Simple distances for trajectories via landmarks. In
ACM GISSIGSPATIAL , 2019.[41] Jeff M. Phillips and Pingfan Tang. Sketched mindist. In
International Symposium on ComputationalGeometry , 2020.[42] Ilya Razenshteyn and Ludwig Schmidt. Falconn-fast lookups of cosine and other nearest neighbors. https://falconn-lib.org , 2018.[43] G. Rote. Curves with increasing chords.
Math. Proc. Cambridge Philos. Soc. , 115:1–12, 1994.[44] M.I. Schlesinger, E.V. Vodolazskiy, and V.M. Yakovenko. Similarity of closed polygonal curves inFrechet metric.
International Journal of Computational Geometry & Applications , 11(6), 2018.[45] Zeyuan Shang, Guoliang Li, and Zhifeng Bao. Dita: Distributed in-memory trajectory analytics. In
SIGMOD , 2018.[46] Martin Werner and Dev Oliver. Acm sigspatial gis cup 2017: Range queries under fr´echet distance.
SIGSPATIAL Special , 10(1):24–27, 2018.[47] Ben H Williams, Marc Toussaint, and Amos J Storkey. A primitive based generative model to infertiming information in unpartitioned handwriting data. In
IJCAI , pages 1119–1124, 2007.[48] Dong Xie, Feifei Li, and Jeff M. Phillips. Distributed trajectory similarity search. In
VLDB , 2017.[49] Yu Zheng, Hao Fu, Xing Xie, Wei-Ying Ma, and Quannan Li.
Geolife GPS trajectory dataset - UserGuide , July 2011. 13
Relation of d mD Q to the Hausdorff distance In this section we show that the unsigned variant of the sketch v mD q i ( γ ) based only on the minDist function,has a strong relationship to the Hausdorff distance. In particular, when Q is dense enough, and the l ∞ variantis used, they are identical. Theorem A.1.
Let γ, γ (cid:48) be two continuous curves and q ∈ R . Then | v mD q ( γ ) − v mD q ( γ (cid:48) ) | ≤ d H ( γ, γ (cid:48) ) . Consequently, d mD Q ( γ, γ (cid:48) ) ≤ d H ( γ, γ (cid:48) ) for any landmark set Q .Proof. Let r = d H ( γ, γ (cid:48) ) . Suppose p = argmin p ∈ γ (cid:107) q − p (cid:107) and p (cid:48) = argmin p (cid:48) ∈ γ (cid:48) (cid:107) q − p (cid:48) (cid:107) . Let also y = argmin y ∈ γ (cid:107) y − p (cid:48) (cid:107) and y (cid:48) = argmin y (cid:48) ∈ γ (cid:107) y (cid:48) − p (cid:107) . Then we have (cid:107) q − p (cid:107) ≤ (cid:107) q − y (cid:107) and (cid:107) q − p (cid:48) (cid:107) ≤(cid:107) q − y (cid:48) (cid:107) and according to the definition of the Hausdorff distance (cid:107) y − p (cid:48) (cid:107) ≤ r and (cid:107) y (cid:48) − p (cid:107) ≤ r . Nowthere are two possible cases:(i) (cid:107) q − p (cid:107) ≤ (cid:107) q − p (cid:48) (cid:107) . Then using the triangle inequality we get ≤ (cid:107) q − p (cid:107) − (cid:107) q − p (cid:48) (cid:107) ≤ (cid:107) q − y (cid:107) − (cid:107) q − p (cid:48) (cid:107) ≤ (cid:107) y − p (cid:48) (cid:107) ≤ r. (ii) (cid:107) q − p (cid:48) (cid:107) ≤ (cid:107) q − p (cid:107) . Then ≤ (cid:107) q − p (cid:48) (cid:107) − (cid:107) q − p (cid:107) ≤ (cid:107) q − y (cid:48) (cid:107) − (cid:107) q − p (cid:107) ≤ (cid:107) y (cid:48) − p (cid:107) ≤ r. Therefore, |(cid:107) q − p (cid:107) − (cid:107) q − p (cid:48) (cid:107)| ≤ r . The next inequality is immediate as we take average in computing d Q . Corollary A.2.
Let Ω ⊂ R be a bounded domain and Q is dense in Ω . If the range of γ, γ (cid:48) are included in Ω , then d mD Q ∞ ( γ, γ (cid:48) ) = d H ( γ, γ (cid:48) ) .Proof. Employing Theorem A.1 we only need to show d mD Q ∞ ( γ, γ (cid:48) ) ≥ d H ( γ, γ (cid:48) ) . Let r = d H ( γ, γ (cid:48) ) .Without loss of generality we can assume that r = sup p ∈ γ min p (cid:48) ∈ γ (cid:48) (cid:107) p − p (cid:48) (cid:107) . Since the range of γ iscompact (the image of a compact set under a continuous map is compact), there is p ∈ γ such that r =min p (cid:48) ∈ γ (cid:48) (cid:107) p − p (cid:48) (cid:107) . Similarly, by continuity of the range of γ (cid:48) we conclude that there is p (cid:48) ∈ γ such that r = (cid:107) p − p (cid:48) (cid:107) . Because Q is dense in Ω , without loss of generality, with an ε -discussion, we may assumethat p ∈ Q . Since p (cid:48) = argmin p (cid:48) ∈ γ (cid:48) (cid:107) p − p (cid:48) (cid:107) , we observe that v mD p ( γ (cid:48) ) = (cid:107) p − p (cid:48) (cid:107) = r . On the other hand, v mD p ( γ ) = 0 as p ∈ γ . Therefore, at least one of the components of the sketched vector v mD Q ( γ (cid:48) ) − v mD Q ( γ ) is r and so d mD Q ∞ ( γ, γ (cid:48) ) ≥ r . B Technical Details on Defining the Normal and Computing v q ( γ ) We need to assign a normal vector to each point of a curve γ . Let γ ∈ Γ (cid:48) and q ∈ R . Assume p =argmin p (cid:48) ∈ γ (cid:107) q − p (cid:48) (cid:107) . If p ∈ reg( γ ) , as we mentioned earlier, according to the right hand rule, we can assigna unit normal vector to γ at p which is compatible with the direction of γ . We also assign a fixed normalvector at endpoints of a non-closed curve as we can use the normal vector of tangent line at endpoints thatis compatible with the direction of curve. Now it remains to define a normal vector at critical points. Wemust be careful about doing this as any vector can be considered as a normal vector at critical points. Ouraim is to define a unique normal vector at critical points with respect to a landmark point. Assume p is notan endpoint of γ . Denote by N ( p ) the closure of the set of all unit vectors u such that u is perpendicular to γ at p and is compatible with the direction of γ by the right hand rule (for instance, in Figure 6(a), N ( p ) isthe set of all unit vectors between n and n (cid:48) ). Notice that for regular points on the curve N ( p ) is a singletonand indeed, it does not depend on q but only on the direction of curve. Then we define n p ( q ) = argmax (cid:8) |(cid:104) u, q − p (cid:105)| : u ∈ N ( p ) (cid:9) .
14t can be readily seen that n p ( q ) = sign( q, p, γ ) q − p (cid:107) q − p (cid:107) , where sign( q, p, γ ) can be obtained via AlgorithmB.1. At endpoints we fix a normal vector, the one that is perpendicular to the tangent line. Notice, as therange of γ is a compact subset of R and the norm function is continuous, the point p exists. Continuity of theinner product and compactness of N ( p ) guarantee the existence of n p ( q ) as well. (A different algorithmicapproach for finding n p ( q ) , when p is a critical point, is given below.) B.1 Computing n p ( q ) and the Sign Assume that a trajectory γ is given by the sequence of its critical points (including endpoints) { c i } ni =0 and (cid:107) c i − c i +1 (cid:107) > for each ≤ i ≤ n − . The following algorithm determines the sign of a landmark point q with respect to γ when p = argmin {(cid:107) q − x (cid:107) : x ∈ γ } is a critical point of γ . Algorithm B.1
Find sign( q, p, γ ) Input:
A landmark q ∈ R , a trajectory γ = { c i } ni =0 and p = c i for some ≤ i ≤ n .Find w i (unit normal vector to the directed segment −−−→ c i c i +1 ).Find α (the angle between w i − and w i ).Find θ (the angle between w i − and q − p ).Put t = (1 − cos( πθα )) .Let n t be the normalized convex combination of w i − and w i by t . return sign( (cid:104) n t , q − p (cid:105) ) .Because each step in Algorithm B.1 takes constant time, it is clear that the running time is O (1) . Now,in Algorithm B.2, for a landmark point q ∈ R and a trajectory γ we provide steps to compute the sketchvector v q ( γ ) . Algorithm B.2
Compute v q ( γ ) Input:
A landmark q ∈ R and a trajectory γ = { c i } ni =0 . for i = 0 , , . . . , n − do Find d i , the distance of c i from directed segment S i = −−−→ c i c i +1 .Find l i the signed distance of q to the directed line through the directed segment S i .Set j = argmin { d i : 0 ≤ i ≤ n − } .Set p = argmin {(cid:107) q − x (cid:107) : x ∈ S j } .Using Algorithm B.1 compute v q ( γ ) . return v q ( γ ) .It can be readily seen that Algorithm B.2 can be run in linear time in terms of the size of γ . Details areincluded in Appendix B.3. B.2 Defining the Normal: A Computational Approach
If we look at self-crossing curves, for instance, we will notice that the landmark point q will opt for thecrossing point p only if tangent lines of γ at p (where q lies in it) make an angle β ≥ π (see Figure 5).Therefore, there is no need to define a normal vector for such crossing points and without loss of generalitywe may assume that β ≥ π .Let γ be a curve with β ≥ π at a crossing point p (Figure 5(b),(c)). For t ∈ [0 , we consider n t = (1 − t ) n + tn (cid:48) (cid:107) (1 − t ) n + tn (cid:48) (cid:107) , where n and n (cid:48) are normal vectors to the curve at a crossing point p . It is necessary to agreethat n / = 0 if n (cid:48) = − n which is possible when β = π . Now the question is how to choose the parameter15 p + − + 0bisector αn t n (cid:48) nα θ + − qn n (cid:48) + + ++ − − + pp q q q q q q β tangent line tangent line β ( a ) ( b ) ( c ) Figure 5: Choice of self-crossing point t ? Let α be the angle between n and n (cid:48) and θ be the angle between n and q − p (as shown in Figure 5(b),(c)),i.e. α = arccos( (cid:104) n, n (cid:48) (cid:105) ) and θ = arccos( (cid:104) n, q − p (cid:107) q − p (cid:107) (cid:105) ) . Then < α ≤ π and ≤ θ ≤ α and thus ≤ πα θ ≤ π . Now we can set n t = 1 − cos( πα θ )2 . Therefore, thefollowing hold:1. If θ = 0 , then t = 0 , q is on the left dashed green line in Figure 5(c) and n t = n = q − p (cid:107) q − p (cid:107) .2. Moving towards the bisector, n t rotates towards n (cid:48) and so θ increases (but still θ < π/ ). Hence (cid:104) n t , q − p (cid:105) is positive and is decreasing as a function of θ .3. When θ = α , t = and q is on the bisector of θ and (cid:104) n t , q − p (cid:105) = 0 (Figure 5(c)).4. Moving from bisector towards the other side of the green dashed angle, θ increases and θ > π/ .Thus (cid:104) n t , q − p (cid:105) is negative and decreases.5. If θ = α , then t = 1 , q is on the right dashed green line in Figure 5(c) and n t = n (cid:48) = − q − p (cid:107) q − p (cid:107) .However, we will only need to compute the inner product of n t and g − p , which can easily be obtained by (cid:104) n t , q − p (cid:105) = (cid:107) q − p (cid:107) cos( πα θ ) . The way we defined n t is a general rule for any crossing and critical point. Now we are going to clarifyobtaining n t in different situations.1. Let p be a critical point which is not a crossing point of γ . Then as above a landmark point q willchoose p as an argmin point only if tangent lines at p constitute an angle β ≥ π and q is inside of thatarea (Figure 6(a)). In this case we can easily see that n t = q − p (cid:107) q − p (cid:107) for any t .2. In self-crossing case of Figure 5(b), again we can observe that n t = q − p (cid:107) q − p (cid:107) for any t .3. If p is an end point, we consider n as the normal vector at p to the tangent line at p to γ and we set n (cid:48) = − n . Then for t ∈ [0 , ) , n t = n , n / = 0 and for t ∈ ( , , n t = − n (see Figure 6(b)).As we saw above, n t depends upon the landmark point q , that is, a critical point p can be an argmin pointfor many landmark points q . Therefore, we use the notation n p ( q ) instead of n t . For p ∈ reg( γ ) we set n p ( q ) = n p for any q such that p = argmin p (cid:48) ∈ γ (cid:107) q − p (cid:48) (cid:107) .16 .3 The Algorithmic Steps Detailed versions of Algorithms B.1 and B.2 are included here.
Algorithm B.3
Find sign( q, p, γ ) Input:
A landmark q ∈ R and a trajectory γ = { c i } ni =0 , where c i = ( a i , b i ) ∈ R and p = c i for some ≤ i ≤ n . if ≤ i ≤ n − then Set w i = ( b i +1 − b i , a i − a i +1 ) / (cid:107) ( b i +1 − b i , a i − a i +1 ) (cid:107) and w (cid:48) i = w i − . if i = 0 then Set w = ( b − b , a − a ) / (cid:107) ( b − b , a − a ) (cid:107) and w (cid:48) = − w . if i = n then Set w n = w n − and w (cid:48) n = − w n − .Set α = arccos( (cid:104) w i , w (cid:48) i (cid:105) ) and θ = arccos( (cid:104) w i , q − p (cid:107) q − p (cid:107) (cid:105) ) .Set t = (1 − cos( πθα )) and n t = ((1 − t ) w i + tw (cid:48) i ) / (cid:107) (1 − t ) w i + tw (cid:48) i (cid:107) . return sign( (cid:104) n t , q − p (cid:105) ) . Algorithm B.4
Compute v q ( γ ) Input:
A landmark q ∈ R and a trajectory γ = { c i } ni =0 , where c i = ( a i , b i ) ∈ R . for i = 0 , , . . . , n − do S i = segment( c i , c i +1 ) = −−−→ c i c i +1 . L i = line passing from c i , c i +1 with normal vector w i = ( b i +1 − b i , a i − a i +1 ) .Set l i = signeddist( q, L i ) , d i = dist( q, S i ) = min {| l i | , (cid:107) q − c i (cid:107) , (cid:107) q − c i +1 (cid:107)} .Set j = argmin { d i : 0 ≤ i ≤ n − } , p = argmin {(cid:107) q − x (cid:107) : x ∈ S j } . if p is an internal point of S j then Set v = σ l j e − l j /σ . if p is not an endpoint of γ , i.e. p (cid:54) = c , c n then Set v = σ sign( q, p, γ ) d j e − d j /σ . if p = c then Set v = σ (cid:104) q − c (cid:107) q − c (cid:107) , w (cid:107) w (cid:107) (cid:105) max( |(cid:104) q − c , w (cid:107) w (cid:107) (cid:105)| , |(cid:104) q − c , c − c (cid:107) c − c (cid:107) (cid:105)| ) e − d /σ . if p = c n then Set v = σ (cid:104) q − c n (cid:107) q − c n (cid:107) , w n − (cid:107) w n − (cid:107) (cid:105) max( |(cid:104) q − c n , w n − (cid:107) w n − (cid:107) (cid:105)| , |(cid:104) q − c n , c n − c n − (cid:107) c n − c n − (cid:107) (cid:105)| ) e − d n − /σ . return v .Since every step in the for-loop of Algorithm B.4 needs O (1) time to be computed, the for-loop onlyneeds O ( n ) time where n is the number of critical points of γ . Note that l i can be computed by l i = ( b i +1 − b i ) x + ( a i − a i +1 ) y + a i +1 b i − b i +1 a i a + b , where a = a i − a i +1 , b = b i +1 − b i . Finding the minimum of an array takes a linear time in size of thearray, so j needs O ( n ) time to be computed. Obviously, p needs only a constant time as it is p i or p i +1 or (cid:16) a ( ax − by ) − bca + b , b ( by − ax ) − bca + b (cid:17) , where c = b i +1 a i − a i +1 b i . The rest of the algorithm requires O (1) time considering the fact that calculating sign( q, γ ) , utilizing Algorithm B.1, takes a constant time. Therefor, Algorithm B.2 will be run in linear timein terms of the critical points of γ . 17 − n q q q q q γ In this region n t = n In this region n t = − n pqpn n (cid:48) + ++ ++ − β ( a ) ( b ) tangent line γ Figure 6: Matching of n t with n p ( q ) B.4 A simple proof for Corollary 3.5 for convex curves without using algebraic topol-ogy techniques
Corollary B.1.
Let γ, γ (cid:48) ∈ Γ be closed and convex, with both oriented clockwise/counterclockwise. Then d σQ ( γ, γ (cid:48) ) ≤ σ d F ( γ, γ (cid:48) ) .Proof. Because every continuous curve can be approximated by smooth curves, without loss of generalitywe may assume that γ and γ (cid:48) are smooth. Let q ∈ Q be arbitrary and let A and A (cid:48) denote the regionssurrounded by γ and γ (cid:48) respectively. If q is in A ∩ A (cid:48) or in the complement of A ∪ A (cid:48) , then v q ( γ ) and v q ( γ (cid:48) ) would have a same sign and so Condition (1) in Theorem 3.3 holds. Otherwise, q will be in A \ A (cid:48) or A (cid:48) \ A .Assume that q lies in A (cid:48) \ A (the case A \ A (cid:48) comes by symmetry). Let p ∈ γ be the closest point of γ to q .Obviously, q − p is perpendicular to γ . Now let p (cid:48) be the intersection of γ (cid:48) and the half-line starting from p and passing through q . Then p is the closest point of γ to p (cid:48) (since p − p (cid:48) is normal to γ at p and γ is convex)and q lies on the line segment pp (cid:48) . Let p (cid:48)(cid:48) be the nearest point of γ (cid:48) to q . Then according to the direction ofcurves we have | v q ( γ ) − v q ( γ (cid:48) ) | = 1 σ (cid:107) q − p (cid:107) e −(cid:107) q − p (cid:107) σ + 1 σ (cid:107) q − p (cid:48)(cid:48) (cid:107) e − (cid:107) q − p (cid:48)(cid:48)(cid:107) σ ≤ σ ( (cid:107) q − p (cid:107) + (cid:107) q − p (cid:48)(cid:48) (cid:107) ) ≤ σ ( (cid:107) q − p (cid:107) + (cid:107) q − p (cid:48) (cid:107) )= 1 σ (cid:107) p − p (cid:48) (cid:107) ≤ σ d H ( γ, γ (cid:48) ) ≤ σ d F ( γ, γ (cid:48) ) ..