scieee AI-readable full text Open interactive document viewer

Metrics and barycenters for point pattern data

Müller, Raoul; Schuhmacher, Dominic; Mateu, Jorge

Abstract

We introduce the transport–transform and the relative transport–transform metrics between finite point patterns on a generalspace, which provide a unified framework for earlier point pattern metrics, in particular the generalized spike time and thenormalized and unnormalized optimal subpattern assignment metrics. Our main focus is on barycenters, i.e., minimizersof aq-th-order Fréchet functional with respect to these metrics. We present a heuristic algorithm that terminates in a localminimum and is shown to be fast and reliable in a simulation study. The algorithm serves as a general plug-in method that canbe applied to point patterns on any state space where an appropriate algorithm for solving the location problem for individualpoints is available. We present applications to geocoded data of crimes in Euclidean space and on a street network, illustratingthat barycenters serve as informative summary statistics. Our work is a first step toward statistical inference in covariate-basedmodels of repeated point pattern observations.

Full text

Statistics and Computing (2020) 30:953–972 https://doi.org/10.1007/s11222-020-09932-y Metrics and barycenters for point pattern data Raoul Müller1·Dominic Schuhmacher1·Jorge Mateu2 Received: 19 September 2019 / Accepted: 11 February 2020 / Published online: 24 February 2020 © The Author(s) 2020 Abstract We introduce the transport–transform and the relative transport–transform metrics between finite point patterns on a general space, which provide a unified framework for earlier point pattern metrics, in particular the generalized spike time and the normalized and unnormalized optimal subpattern assignment metrics. Our main focus is on barycenters, i.e., minimizers of a q-th-order Fréchet functional with respect to these metrics. We present a heuristic algorithm that terminates in a local minimum and is shown to be fast and reliable in a simulation study. The algorithm serves as a general plug-in method that can be applied to point patterns on any state space where an appropriate algorithm for solving the location problem for individual points is available. We present applications to geocoded data of crimes in Euclidean space and on a street network, illustrating that barycenters serve as informative summary statistics. Our work is a first step toward statistical inference in covariate-based models of repeated point pattern observations. Keywords Fréchet mean ·Fréchet median ·Network ·Optimal transport ·Point process ·Unbalanced ·Wasserstein 1 Introduction Point pattern data are abundant in modern scientific studies. From biomedical imagery over geo-referenced disease cases and positions of mobile phone users to climate changerelated space–time events, such as landslides, we have more and more complicated data available. See Chiaraviglio et al. (2016), Lombardo et al. (2018), Konstantinoudis et al. (2019), Samartsidis et al. (2019) for individual examples and the textbooks Diggle (2013), Baddeley et al. (2015), Błaszczyszyn et al. (2018) for a broad overview of further applications. While a few decades ago, data consisted typically of a single point pattern in a low-dimensional Euclidean space, maybe with some low-dimensional mark information, we have nowadays often multiple observations of point patterns available that may live on more complicated spaces, Raoul Müller is supported by Deutsche Forschungsgemeinschaft GRK 2088. Jorge Mateu is supported by MTM2016-78917-R from the Spanish Ministry of Economy and Competitiveness. BRaoul Müller [email protected] 1Institute for Mathematical Stochastics, University of Göttingen, 37077 Göttingen, Germany 2Department of Mathematics, University Jaume I, 12071 Castellón, Spain e.g., manifolds (including shape spaces), spaces of convex sets or function spaces. A setting that has received a particularly large amount of attention recently is point patterns on graphs, such as street networks, see Moradi et al. (2018), Moradi and Mateu (2019) and Rakshit et al. (2019) among others. Multiple point pattern observations may occur by i.i.d. replication (e.g., of a biological experiment), but may also be governed by one or several covariates or form a time series of possibly dependent patterns. Additional mark information can easily be high-dimensional. Methodology for treating such point pattern data in all these situations is the subject of ongoing statistical research, see, e.g., Baddeley et al. (2015). From a more abstract point of view, consider the set Nfin of finite counting measures on some metric space (X,d). If we manage to equip Nfin with a metric τthat reflects the concept of distance between point patterns in an appropriate problem-related way, there are a number of standard methods which can be applied, including multidimensional scaling, discriminant and cluster analysis techniques. This is a stance already taken in Schuhmacher (2014), Section 1.4, and Mateu et al. (2015). In the metric space (Nfin,τ),we can furthermore define a Fréchet mean of order q≥1; that is, for data ξ1,...,ξ k∈Nfin any ζ∈Nfin minimizing 123 954 Statistics and Computing (2020) 30:953–972 Fig. 1 An example of barycenters computed by our algorithm for three different data sets. In each panel, there are three data point patterns indicated by different symbols (black). The resulting (pseudo-)barycenter pattern with respect to Euclidean distance is given by the blue circles (p=q=2). (Color figure online) k  j=1 τ(ξj,ζ) q.(1) Such a q-th-order mean may serve as a “typical” element of Nfin to represent the data and gives rise to more complex statistical analyses, such as Fréchet regression; see Lin and Müller (2019) and Petersen and Müller (2019). Two metrics on the space of point patterns that have been widely used are the spike time metric, see Victor and Purpura (1997) for one dimension and Diez et al. (2012) for higher dimension, and the optimal subpattern assignment (OSPA) metric, see Schuhmacher and Xia (2008) and Schuhmacher etal.(2008).Inthepresent paper, weintroducethetransport– transform (TT) metric andits normalized version,the relative transport–transform (RTT) metric, which provide a unified framework for the earlier metrics. Both the TT- and the RTT- metrics are based on matching the points between two point patterns on Xoptimally in terms of some power pof dand penalizingpointsthatcannotbereasonablymatched.Wemay interpret these metrics as unbalanced p-th-order Wasserstein metrics, see Remark 3below. In the present paper, we always set p=q. Among others Schoenberg and Tranbarger (2008), Diez et al. (2012) and Mateu et al. (2015) have treated Fréchet means of order 1 (medians) for the spike time metric under the name of prototypes. However, computations in 2d and higherwereonlypossibleforverysmalldatasetsduetoaprohibitivecomputationalcostof O(n6)forthedistancebetween two point patterns with npoints each. In the present work, we use an adapted auction algorithm that is able to compute TT- and RTT-distances between point patterns in O(n3).We further provide a heuristic algorithm that bears some resemblance to a k-means cluster algorithm and is able to compute local minima of the barycenter problem very efficiently. This makesitpossibletocompute“quasi-barycenters”for100pat- terns of 100 points in R2in a few seconds when basing the TT-distance on the Euclidean distance between points and choosing p=q=2. In Fig. 1, we show some typical barycenters obtained by our algorithm in this setting. We use smaller data sets for better visibility. In each scenario, there are three different point patterns distinguished by the different symbols in black. The (pseudo-)barycenter represented by the blue circles captures the characteristics of each data set rather well. Some minor irregularities, especially in the third panel, may be due to the fact that only a (good) local optimum is computed. More important than being fast for point pattern data on RDwhen using squared Euclidean distances is the fact that our algorithm provides a general plug-in method that can in principle be used for point patterns on any underlying space Xwhere an appropriate “cost function” between objects is specified as p-th power of a metric d. All that is required is an algorithm that finds (maybe heuristically) a p-th-order Fréchet mean for individual points in X, i.e., finds z∈X minimizing k j=1d(xj,z)pfor any given x1,...,xk∈X. We refer to this in what follows as the underlying location problem. The reduction to the underlying location problem allows us to treat the case of point patterns on a network equipped with the shortest-path metric and p=1. Figure 2 gives an example for crime data in Valencia, Spain, which we study in more detail in Sect. 6. The barycenter problem we consider in this paper is closely related to the problem of computing an unbalanced Wasserstein barycenter, see, e.g., Chizat et al. (2018). However,ratherthanminimizinga Fréchetfunctionalonthespace of all measures, we minimize on the space Nfin of Z+-valued measures, see Remark 5. The plan of the paper is as follows. In Sect. 2,weintroduce the TT- and RTT-metrics and discuss their relations to spike time, OSPA, and incomplete Wasserstein metrics. Sec- 123 Statistics and Computing (2020) 30:953–972 955 Fig. 2 An example of a barycenter on a street network. Shown are 8 patterns of assault crimes during the summer months of 2010–2017 in the old town of Valencia (all in gray for better overall visibility). The resulting barycenter with respect to shortest-path distance along the streets is given in blue, with multipoints in purple (p=q=1). (Color figure online) tion 3specifies what we mean by a barycenter (or Fréchet mean) with respect to these metrics and gives an important result that forms the basis for our heuristic algorithm. Two versions of this algorithm, a more direct one and an improved one, which saves computation steps that are unlikely to substantially influence the final result, are discussed in detail in Sect. 4, along with some practical aspects. Section 5contains a larger simulation study, which investigates robustness and runtime performances of the two algorithms for the case of Euclidean distance and p=2. Finally, we give two applications to data of crime events on a city map for real data in Sect. 6. The first one concerns street thefts in Bogotá, Colombia. We treat this again as data in Euclidean space, using p=2. The second one deals with assault cases in the streets of Valencia, Spain. Here, we compute barycenters based on the actual shortest-path distance on the street network and use p=1. 2 The transport–transform metric Denote by Nfin the space of finite point patterns (counting measures) on a complete separable metric space (X,d), equippedwiththeusualσ-algebraNfin generatedbythepoint count maps ΨA:Nfin →R,ξ→ ξ(A)for A⊂XBorel measurable. Elements of Nfin are typically denoted by ξ,η,ζ here. As usual, we write δxfor the Dirac measure with unit mass at x∈X. In the present section, we mostly use measure notation such as ξ=n i=1δxi,ξ({x})≥1orξ+η,but in later sections we also use corresponding (multi)set notation such as ξ={x1,...,xn},x∈ξor ξ∪ηwhere this is unambiguous. We use |ξ|=ξ(X)to denote the total number of points in the pattern ξ.Forn∈Z+={0,1,2,...}write [n]= {1,2,...,n}(including [0]=∅) and denote by Nnthe set of point patterns with exactly npoints. We first introduce the metrics we use on Nfin, which unify and generalize two of the main metrics used previously in the literature. Definition 1 Let C>0 and p≥1 be two parameters, referred to as penalty and order, respectively. (a) For ξ=m i=1δxi,η =n j=1δyj∈Nfin, define the transport–transform (TT) metric by τ(ξ,η) =τC,p(ξ, η) =min(m+n−2l)Cp+ l  r=1 d(xir,yjr)p1/p , (2) wheretheminimumistakenoverequalnumbersofpairwise different indices i1,...,ilin [m]and j1,..., jlin [n], i.e. over the set S(m,n)=(i1,...,il;j1,..., jl); l∈{0,1,...,min{m,n}}, i1,...,il∈[m]pairwise different, j1,..., jl∈[n]pairwise different. (b) Forξ,η ∈Nfin, define the relative transport–transform (RTT) metric by ¯τ(ξ,η) =¯τC,p(ξ, η) =1 max{|ξ|,|η|}1/pτC,p(ξ, η). (3) We state and prove below that τand ¯τare indeed metrics. The following result simplifies proofs of statements about thesemetricsandisfurthermoreinvaluablefortheircomputation. The idea is to extend the metric space (X,d∧(21/pC)), where [d∧(21/pC)](x,y)=min{d(x,y), 21/pC},bysetting X=X∪{ℵ}for an auxiliary element ℵ/∈Xand d(x,y)=⎧ ⎪ ⎨ ⎪ ⎩ min{d(x,y), 21/pC}if x,y∈X; Cif ℵ∈{x,y},x= y; 0ifx=y=ℵ. ItisshowninLemmaA.1that(X,d)isametricspaceagain. We may then compute distances in the τand ¯τmetrics by 123 956 Statistics and Computing (2020) 30:953–972 solving an optimal matching problem between point patterns with the same cardinality. For n∈Ndenote by Sn,thesetof permutations on [n]. Theorem 1 Let ξ=m i=1δxi,η =n j=1δyj∈Nfin, where w.l.o.g. m ≤n (otherwise swap ξand η). Set xi=ℵfor m+1≤i≤n and ˜ ξ=n i=1δxi. Then, τ(ξ,η) =min π∈Sn n  i=1 d(xi,yπ(i))p1/p and ¯τ(ξ,η) =1 nmin π∈Sn n  i=1 d(xi,yπ(i))p1/p . The proof of this and the other theorems in this section can be found in the appendix. Remark 1 (Computation of TT- and RTT-metrics) Writing nfor the maximum cardinality as in Theorem 1, this result shows that we can compute both τ(ξ,η)and ¯τ(ξ,η)in worsttime complexity of O(n3)by using the classic Hungarian method for the assignment problem; see Kuhn (1955). In practice, we use the auction algorithm proposed in Bertsekas (1988), because it has usually much better runtime in our experience, although the default version has a somewhat worse worst-case performance of O(n3log(n)).1 Theorem 2 The maps τand ¯τare metrics on Nfin. The next result establishes our previous claim that the new transport–transform construction generalizes two metrics on Nfin previously used in the literature. Theorem 3 (a) If p =1, then for any ξ,η ∈Nfin τ(ξ,η) =min (ξ0,...,ξN) N−1  i=0 celem(ξi,ξ i+1), (4) where the minimum is taken over all N ∈Nand all paths (ξ0,...,ξN)∈NN+1 fin such that ξ0=ξ,ξN=η, and from ξito ξi+1either a single point is added or deleted at cost celem(ξi,ξ i+1)=C or a single point is moved from x to y at cost celem(ξi,ξ i+1)=d(x,y). (b) If diam(X)=supx,y∈Xd(x,y)≤21/pC, then for any ξ=m i=1δxi,η =n j=1δyj∈Nfin, assuming w.l.o.g. m≤n 1There is a modified auction algorithm that can improve the worstcase performance to O(n5/2log(n)); for the performance discussion see Bertsekas (1988), page 109. Actually, both orders include a factor cin the log which measures the numerical precision, assumed to be bounded here. ¯τ(ξ,η)p=1 n(n−m)Cp+min π∈Sn m  i=1 d(xi,yπ(i))p. (5) Theorem 3(a) implies that the TT-metric is the same as the spike time metric (using add and delete penalties Pa=Pd=Cand a move penalty Pm=1), which was originally introduced on R+by Victor and Purpura (1997) and generalized to metric spaces by Diez et al. (2012). It can be seen from the proof in the appendix that the right hand side of (4) is not a metric in general if p>1. Theorem 3(b) implies that the RTT-metric is the same as the OSPA metric, introduced in Schuhmacher and Xia (2008) and Schuhmacher et al. (2008). Note that in the definition of theOSPA metric diam(X)≤C≤21/pCwaseitherrequired or enforced by taking the minimum of dwith C. Here, it can beseenthattheright hand side of (5) is not ametric in general if diam(X)>2C. Remark 2 (Computation of spike time distances) The spike time distances in Victor and Purpura (1997) and Diez et al. (2012) allowed for separate add and delete penalties Paand Pd, as well as a move penalty Pm(factor in front of d(x,y)). We set here Pa=Pd=Cto obtain a proper metric and divide distances by Pm, which is just a scaling. Thus, the parameter C=Pa/Pm=Pd/Pmis all that remains. As noted at the end of Section 4 in Diez et al. (2012), having different add and delete penalties may be useful for controlling the total number of points in a barycenter point pattern. Let us point out therefore that Theorem 1 is easily adapted to this more general situation by setting d(x,y)=min{d(x,y), 21/p(Pa+Pd)},d(ℵ,y)=Paand d(x,ℵ)=Pdfor all x,y∈X. Inparticular,thisyieldsaworst-timecomplexityof O(n3)for general (maybe asymmetric) spike time distances in general metric spaces, which is a substantial improvement over the O(n6)complexity of the incremental matching algorithm presented in Diez et al. (2012). Remark 3 (Unbalanced Wasserstein metrics) The TT- and RTT-metrics can be seen as unbalanced Wasserstein metrics, see, e.g., Chizat et al. (2018), Liero et al. (2018) and the references therein. Minimizing over the space Mfin of all finite measures on X×X, we obtain the TT-distance as a solution to a particular instance of the unbalanced optimal transport problem in Chizat et al. (2018), Definition 2.11, namely τ(ξ,η)p=inf γ∈MfinX×X d(x,y)pγ(dx,dy) +Cpξ−γ1TV +Cpη−γ2TV, (6) 123 Statistics and Computing (2020) 30:953–972 957 whereγ1=γ(·×X)andγ2=γ(X×·)denotethemarginals ofγ,and·TV isthetotalvariationnormofsignedmeasures; specificallyμ−νTV =supA(μ(A)−ν(A))+supA(ν(A)− μ(A)) for μ, ν ∈Mfin, where the suprema are taken over all measurable subsets of X. Equation (6) can be shown as follows. It is straightforward to see that we may take the infimum on the right hand side only over γ∈Mfin with marginals γ1≤ξand γ2≤η, because any additional mass in γmay be removed without increasing the total cost of γ. Writing ξ=n i=1δxiand η=n i=1δyiwith the help of additional points at ℵ(if necessary), we obtain by similar arguments as in the proof of Theorem 1that the latter problem is equivalent to the discrete transportation problem min (γij)1≤i,j≤n n  i,j=1 d(xi,yj)p·γij s.t. n  j=1 γij =1 for all i, n  i=1 γij =1 for all j, γij ≥0 for all i,j. It is a standard result in linear programming that this problem always has a solution γij ∈{0,1},1≤i,j≤n; see, e.g., the theorem in Section 6.5 of Luenberger and Ye (2008), which is essentially due to the fact that the structure of the constraint allows for a back substitution approach involving only additions and subtractions. We may therefore conclude from Theorem 1that Equation (6) holds and that the infimum on the right hand side is attained for γ=n i,j=11{xi,yj= ℵ}γijδ(xi,yj). In principle, Remark 3allows us to specialize results and algorithms for unbalanced Wasserstein metrics to TT- and RTT-metrics. However, the discrete setting we consider here is sometimes not included in the general theorems or requires a more specialized treatment. Algorithms for computing unbalanced transport plans are typically derived from balanced optimal transport algorithms; a selection can be found in Chizat (2017). The auction algorithm we use in this paper is derived from the auction algorithm used for balanced assignment problems in a similar way. 3 Barycenters with respect to the TT-metric For data on quite general metric spaces, barycenters can formalize the idea of a center element representing the data. In the case of Nfin, we are thus looking for a center point pattern that gives a good first-order representation of a set of data point patterns ξ1,...,ξ k. More formally, we may define a barycenter as the (weighted) q-th-order Fréchet mean with respect to τ; see Fréchet (1948). Definition 2 For k∈N,letξ1,...,ξ k∈Nfin be data point patterns and λ1,...,λ k>0 with k j=1λj=1 be weights. Let furthermore q≥1. Then, we call any ζ∗∈arg min ζ∈Nfin k  j=1 λjτ(ξj,ζ) q(7) a(weighted) barycenter of order q. If no weights are specified, we tacitly assume that λj=1/kfor 1 ≤j≤k, leading to an “unweighted” barycenter. Remark 4 For q=2, barycenters on general metric spaces are simply known as (empirical) Fréchet means.Forq=1, they are sometimes known as Fréchet medians. This comes from the fact that given x1,...,xk∈RD,wehave arg min z∈RD k  j=1 xj−z2=1 k k  j=1 xj(8) (the arg min is unique here), and that given x1,...,xk∈R,wehave arg min z∈R k  j=1 xk−z=median{x1,...,xk},(9) where the right hand side denotes the set of medians z∈ R;#{j;xj≤z}=#{j;xj≥z}. Remark 5 As seen in Remark 3, we may interpret τas an unbalanced Wasserstein metric. There has been a great deal of research on Wasserstein barycenters (in the Fréchet mean sense as above, see, e.g., Agueh and Carlier (2011) or Cuturi and Doucet (2014)), which more recently also extends to unbalancedWassersteinmetrics,see,e.g.,Chizatetal.(2018) or Schmitz et al. (2018). In addition to the fact that much of the corresponding theory is not well adapted to the case of discrete input measures, with the notable exception of Anderes et al. (2016), we point out that a fundamental difference of (7) lies in the fact that we minimize over the space Nfin of Z+-valued measures. This space is smaller than the space Mfin of general finite measures, but has a more complicated structure because it decays into connected components Nn={ξ∈Nfin;|ξ|=n}(under the TT-metric), implying, e.g., that continuous optimization procedures will not work directly. In what follows, we always set p=qand choose this number mostly ∈{1,2}. We refer to the resulting barycenters simply as 1- and 2-barycenter or as point pattern median and point pattern mean, respectively. Point pattern medians have been introduced under the name of prototypes in Schoenberg 123 958 Statistics and Computing (2020) 30:953–972 andTranbarger(2008)onRandstudiedinhigher dimensions in Diez et al. (2012) and Mateu et al. (2015). However, in these papers the applicability was limited to rather small data sets due to the large computation cost of O(n6)mentioned in Remark 2. Using the construction from Theorem 1, we may reformulate the barycenter problem as a multidimensional assignment problem, generalizing Lemma 16 in Koliander et al. (2018). Note that for the TT-metric we can add an arbitrary number of points at ℵto both point patterns without changing the minimum in Theorem 1. Theorem 4 For point patterns ξj=nj i=1δxij,j∈[k],let ˜n:= 2 k+1k j=1njand n ≥max{˜n,nj;1≤j≤k}. Set xij =ℵfor n j+1≤i≤n and ˜ ξj=n i=1δxij for any j∈[k]. Then, for any π∗,1,...,π ∗,k∈Snjointly minimizing n  i=1 min z∈X k  j=1 d(xπj(i), j,z)p(10) the point pattern ζ∗|Xwith ζ∗=n i=1δzi, where zi∈ arg minz∈Xk j=1d(xπ∗,j(i), j,z)pis a p-th-order barycenter with respect to the TT-metric. The π∗,1,...,π ∗,k∈Snabove define ndisjoint “clusters” Ci={xπ∗,j(i), j;1≤j≤k}, where each contains exactly one (maybe virtual) point of each point pattern. The minimization of (10) may thus be interpreted as a multidimensional assignment problem with cluster cost cost∗(C)=min z∈X x∈C d(x,z)p.(11) Proof Let us first give an upper bound on the cardinality of the barycenter. A single barycenter point can be matched with up to kpoints (one from each point pattern). If said point is matched with only k 2points or fewer, it cannot be worse to delete it. The contribution for this point in the objective function is at least k 2C, while deleting it adds at most k 2Cto the objective function. So, every barycenter point should be matched with at least k+1 2points. The total number of points is k j=1nj. Therefore, the number of barycenter points is bounded above by ˜n=2 k+1k j=1nj. It is thus sufficient to fill up all the point patterns ξjto n points and work also with an ansatz of npoints for ζ. Theorem 1yields min ζ∈Nfin k  j=1 τ(ξj,ζ)p =min z1,...,zn∈X k  j=1 min π∈Sn n  i=1 d(xπ(i), j,zi)p =min z1,...,zn∈Xmin π1,...,πk∈Sn k  j=1 n  i=1 d(xπj(i), j,zi)p =min π1,...,πk∈Sn n  i=1 min zi∈X k  j=1 d(xπj(i), j,zi)p (12) and that any minimizer ζ∗|X=n i=1δzi|Xon the left hand side is obtained from jointly minimizing in π1,...,π kand z1,...,znon the right hand side.  4 Alternating clustering algorithms Based on Theorem 4, we propose an algorithm that alternates between minimizing k  j=1 n  i=1 d(xπj(i), j,zi)p(13) inπ1,...,π k∈Snandinz1,...,zn∈Xuntilconvergence. Suchanalgorithmterminatesinalocalminimumof (13)after a finite number of steps, because (13) can never increase and the minimization in the permutations is over a finite space. Since this underlying idea is close to the popular k-means clustering algorithm, we named the main function in the pseudocode and in the actual implementation kMeansBary (note, however, that nplays the role of kin our notation). Similar alternating algorithms in the context of Wasserstein- 2 barycenters for finitely supported probability measures have been proposed in Cuturi and Doucet (2014), Borgwardt (2019) and del Barrio et al. (2019). See Sect. 5, where we compare results between kMeansBary and Algorithm 2 in Cuturi–Doucet. In what follows, we present pseudocode along with the underlying ideas and explanations for two versions of the kMeansBary-algorithmthatweduboriginal andimproved. Here, “improved” refers to the fact that we cut down on certaincomputation steps inordertosaveruntime.We willseein Sect. 5that this comes essentially without any performance loss. User-friendly implementations of both algorithms are publicly available in the R-package ttbary; see Müller and Schuhmacher (2019). 123 Statistics and Computing (2020) 30:953–972 959 4.1 Our original kMeansBary algorithm The pseudocode for the basic alternating strategy described above is given in Algorithm 1. We have introduced a stopping parameter δto allow termination before the local optimum is reached. Since we are not interested in the actual clustering, but onlyinthe positionofthe centers z1,...,zn,itseemsvery unlikely (though possible) that the solution changes substantially once the cost decrease has become very small. What is more, such a change might be spurious due to rounding errors in the data or when we use an approximation method for optimizing in the centers. Note also that we can always set δto the smallest representable positive floating-point number to ensure convergence to the local optimum. Algorithm 1: kMeansBary. Dependence on data pplist suppressed for simplicity. Input : center an initial pseudo-barycenter; pplist the list of data point patterns; δ>0 a constant for the termination; Nthe maximum number of iterations. Output : Locally optimal pseudo-barycenter center. 1perm,cost ←optimPerm(center); 2for it ←1to Ndo 3costold ←cost; 4center ←optimBary(perm,center); 5center ←optimDelete(perm,center); 6center ←optimAdd(perm,center); 7perm,cost ←optimPerm(center); 8if costold −cost <δthen break;// difference always nonnegative 9end 10 return center;// warn if the loop has run out The minimization with respect to π1,...,π kis performed by optimPerm. This function computes an optimal matching between the current center and each data point pattern in pplist, using an alternating version of the auction algorithm with ε-scaling; see Remark 1and Bertsekas (1988)for more details. We output the cost of the current matching and an n×kmatrix perm, whose j-th column specifies the order in which the points of the j-th data pattern are matched to z1,...,zn. For greater efficiency, we save auxiliary information (price and profit vectors) and use it for initializing the auction algorithm when calling it again with the same data point pattern. For practical purposes, we have split up the minimization with respect to z1,...,zn∈Xinto a function optimBary thatoptimizes the positions within Xandfunctions optimDelete and optimAdd that optimize which of the zito move from Xto ℵand from ℵto X, respectively. Wediscuss details of thesefunctions underthe separateheadings below. In addition to the outputs of the various functions shown in Algorithm 1, we also keep information on the quality of each match of points up to date. We call the match of a zi with a data point xij happy if zi,xij∈Xand d(zi,xij)<21/pC miserable if zi,xij∈Xand d(zi,xi)=21/pC or if zi=ℵ,xij∈X to ℵif xij=ℵ. Note that a miserable match is worst possible in the sense that cost(Ci)=x∈Cid(x,zi)pfor center zicannot increase if xijis replaced by any other x∈X. Details on optimBary The purpose of this function is to find for each zi∈X (i.e., not currently at ℵ) a location in Xthat minimizes cost(Ci)for its current cluster Ci={xπj(i), j;1≤j≤k}. This amounts to a more traditional location problem in X, except that it is typically made (much) more difficult by the fact that we have to truncate distances at 21/pC. Note that any cluster points at ℵcan be ignored because theyalwayscontributethe same amount totheclustercost,no matter where the center lies. The same is true for individual points that have a much larger distance than 21/pCfrom the bulk of the points. However, there are countless scenarios with (groups of) points being around distance 21/pCapart from one another for which the optimization of the cluster cost becomes a difficult optimization problem (piecewise smooth on a space that is fragmented in complicated ways). As a simple heuristic that works well in cases where we do not have to cut too many distances (i.e., Cis not too small), we suggest to ignore all points that are at the maximal d- distance 21/pCfrom the current ziwhen computing the new zi. Note that in this way the cluster cost can never increase. Algorithm 2: optimBary:findoptimalcenterpattern within Xfor given clusters Ci. 1for i←1to ndo 2if zi∈Xthen // ziis the current center of the ith cluster Ci 3happypoints ← {points in Cithat are happily matched to zi}; 4if happypoints != ∅ then 5zi←optimClusterCenter(happypoints); 6end // otherwise ziis deleted in next call to optimDelete 7end 8end 9return {z1,...,zn}; 123 960 Statistics and Computing (2020) 30:953–972 Algorithm 2gives corresponding pseudocode. The function optimClusterCenter handles the location problem for the untruncated metric don X. If for example X=RDequipped with the Euclidean metric and p=2, Equation (8) implies that optimClusterCenter simply has to take the (coordinatewise) average of all happy points. The case p=1 can be tackled with higher computational effort by approximation via the popular Weiszfeld algorithm; see Weiszfeld (1937). As a further instance, which we will take up in Sect. 6, we consider the situation where Xis a simple graph (V,E) equipped with the shortest-path distance and p=1. It can be shown that in this case the location problem in Xis solved by an element ziof V∪Ci, i.e., either a vertex of the graph or any data point, see Hakimi (1964). We therefore proceed by first computing the distance matrix between all these points, whichisthenusedfortheentirealgorithm.Suchshortest-path distance computations in sparse graphs with thousands of points can be performed in (at most) a few seconds by various algorithms, see Chapter 25 in Cormen et al. (2009) and the concrete timing in Sect. 6.2. It is now easy to implement the function optimClusterCenter.Fora given set ofhappy points of a cluster Ci, pick the corresponding columns in the distance matrix, add them up and determine the minimal entry of the resulting vector. If there are several such entries, which due to choosing p=1 can happen quite frequently, we pick one among them uniformly at random. The index of the obtained entry identifies the center point zi. Precomputing the distance matrix between all points of V∪Ciin the graph case has the additional advantage that no distances have to be computed in the optimPerm step. It is, on the other hand, the main bottleneck of the procedure and may not be feasible in situations with very large graphs and data sets. In this case, we can resort to one of the various heuristics available, such as the single and multi-hub heuristics proposed (in principle) in Bandelt et al. (1994) and Koliander et al. (2018). Details on optimDelete This function deletes (i.e., moves to ℵ)anyzi∈Xfor which this operation decreases cost(Ci). We denote by khappy,kmiser and kℵthe numbers of data points in Cithat are happy, miserable and at ℵ, respectively. Write furthermore chappy for the total cost of matching the happy points to zi.Ifzistays in X, the cluster incurs an overall total cost of chappy +kmiser ·2Cp+kℵ·Cp as opposed to khappy ·Cp+kmiser ·Cp if we delete zi. Subtracting kmiser ·Cpfrom both expressions, this leads to the deletion condition khappyCp<chappy +(k−khappy)Cp. Since chappy ≥0, a sufficient condition for deletion is 2khappy <k. We use this as a quick pretest, which allows us to avoid computing chappy sometimes. The full deletion procedure is presented in Algorithm 3. Algorithm 3: optimDelete: move center points from Xto ℵif it decreases cost. 1for i←1to ndo 2if zi∈Nthen 3happypoints ← {points in Cithat are happily matched to zi}; 4khappy ←#happypoints; 5if 2∗khappy <kthen 6zi←ℵ;// shortcut deletion 7else 8chappy ←x∈happypoints d(x,zi)p; 9if khappy ∗Cp<chappy +(k−khappy)∗Cp then zi←ℵ; 10 end 11 end 12 end 13 return {z1,...,zn}; Details on optimAdd This function adds (i.e., moves to X)anyzi∈ℵfor which it finds a way to do so that decreases cost(Ci). Pseudocode is given in Algorithm 4. As a compromise between computational simplicity and finding a good location in X, we first sample a proposal location ˜zuniformly from all miserable data points (i.e., points from any cluster that are currently in a miserable match with their center). Before we consider moving zito ˜z, we rebuild the cluster Ciin such a way that this move has a better chance of being accepted. The corresponding procedure is performed by the optimizeCluster-function in the pseudocode: For each data pattern, ξjpick the miserable point that is closest to ˜z (if it has any) and exchange it with the corresponding point xπj(i), jthat is currently in Ci. Since the point coming from the other cluster was miserable before, the cost of that cluster cannot increase by this exchange. The cost of the cluster Cican increase only if it loses a point located at ℵin the exchange. In this case, the cost increases by Cp, which is compensated by the fact that the cost of the other cluster must decrease, either from 2Cpto Cpif its center is in X,or from Cpto 0 if its center is at ℵ. Thus, the total cost remains 123 Statistics and Computing (2020) 30:953–972 961 the same, but Cihas an additional point in Xnow, which makes the successful addition of zito Xmore likely. To further decrease the prospective cluster cost after addition, we update the proposal ˜zby recentering it in its new cluster using the appropriate optimClusterCenterfunction introduced in optimBary (applied to the set of points of the new cluster that are in a happy match with ˜z). Finally, check whether the cost of the new cluster based on the updated ˜zis smaller than the same cost based on zi=ℵ, which is Cptimes the number kXof non-ℵpoints in the new cluster. Set zito ˜zif this is the case. Algorithm 4: optimAdd: move center points from ℵ to Xif it decreases cost. 1alephindex ←{i∈[n]; zi=ℵ}; 2if alephindex!= ∅ then 3supply ←{data points miserably matched to some zi}; 4for iin alephindex do 5if supply =∅then break; 6˜z←sample(supply,1);// draw uniformly at random from supply 7supply ←supply \{˜z}; 8newcluster,newperm ← optimizeCluster(˜z,perm,i); 9newhappypoints ← {pts in newcluster with happy new match to ˜z}; 10 if newhappypoints != ∅ then ˜z←optimClusterCenter(newhappypoints); 11 kX←#{x∈newcluster;x∈X}; 12 cnew ←x∈newcluster d(x,˜z)p; 13 if cnew <kX∗Cpthen 14 zi←˜z; 15 perm ←newperm; 16 supply ←supply \{x∈supply;xis happy}; 17 end 18 end 19 end 20 return {z1,...,zn}; 4.2 An improved kMeansBary algorithm For obtaining an algorithm with a reduced computational cost, we cut down on steps that are costly, but are not expected to influence the resulting local optimum in a decisive way. Since for now we treat the location problem at the cluster level (performed by optimBary) as very general, allowing a wide range of metric spaces (X,d), we focus here on saving computations in the functions optimPerm, optimDelete, and optimAdd. We have realized that by far the most additions and deletions of points take place in the first two iterations of the original algorithm (see also Fig. 3). Especially checking for addition of points is costly and after the first few iterations very rarely successful. Therefore, we limit such checking henceforward to the first Ndel/add =5 iteration steps. Some further heuristics could be applied in optimAdd,butthe gain in computation time is not so large and they can significantly change the outcome, which is why we decided against implementing them. In optimPerm, we cannot avoid doing matchings. However,theauctionalgorithm weuseallowsto solvearelaxation of the problem by stopping the ε-scaling method early. In general, the auction algorithm with ε-scaling based on a decreasing sequence (ε1,...,ε l)returns successively improved solutions that are guaranteed to lie within nεiof the optimal total cost after the i-th step, see Bertsekas (1988, Proposition 1). By representing rescaled distances as integers in {0,1,...,109}, an optimal matching is obtained in the l-th step if εl<1/n. Our improved algorithm is based on the same ε-vector as the original algorithm, which has components εi=1 n+110l−i,1≤i≤l, where lis chosen in such a way that 107≤ε1<108. As a first improvement, we use the subsequence (εait ,ε ait+1,...,ε bit ), where aand b are prespecified vectors of indices ∈{1,2,...,l}.Asimple choice for aand bthat tends to decrease the runtime noticeably is ait =1 and bit =min{it,l}. Pseudocode for this is presented in Algorithm 5. In practice, we settled for a somewhat more sophisticated improvement. We choose the vectors a=(1,1,1,3,3,3, ...,3,4)and b=(1,2,3,4,6,8,...,2l−1 2,l), and we use the sequence (εaj,ε aj+1,...,ε bj), where j=it for it ∈{1,2,3}, and then jis increased by 1 each time the algorithm would otherwise converge or if the cost increases (which can only happen as long as the matchings are not optimal). This strategy was chosen after analyzing the calculations of the algorithm with respect to the time each calculation takes. In the first two to three iterations, there are a lot of changes in the positions of the barycenter points. Especially in the first iteration, many points are deleted and added, which completely changes the assignments. Therefore, we have to begin the assignment calculation with ε1and to get more sensible results we get more precise with each of the first three iterations. After three iterations, there are usually no big changes to the barycenter anymore, so we can reuse the assignment from the iteration before as a sensible starting solution and can omit ε1and ε2in return. Leaving out the first entries of εtoo soon increases the runtime. Every time the algorithm converges, but has no guaranteed optimal assignment (i.e., bj<l), jis increased by 1, meaning that the next two entries of εare used too, until the end of εis reached. Then, we can safely leave out the first three entries of εwithout increasing the runtime, because at this point the assignments from one iteration to the next only change very little. 123 968 Statistics and Computing (2020) 30:953–972 Ciutat Vella 2 2 2 2 3 Eixample 2 2 7 Extramurs 2 2 22 2 2 3 14 El Pla del Real 2 2 2 2 2 2 2 4 5 2 2 2 23 3 5 Summer Winter Fig. 8 Barycenters of cases of assault for different districts of Valencia in winter and in summer. The numbers indicate multiplicities if there are several points at a single location. The cardinalities of the barycenters are 68, 69, 88, 30 (winter) and 103, 79, 74, 24 (summer) June, July and August), discarding for the present analysis data from the intermediate seasons, as well as from January and February 2010 and December 2017. We then computed barycenters per main season and district, obtaining “typical” assault patterns for summer and winter for each of the four districts considered, see Fig. 8. The penalty was chosen as 800m with respect to the shortest-path distance. As mentioned in Sect. 4.1 when describing the subroutine optimBary that finds cluster centers on networks, we can calculate all distances that are relevant to the algorithm beforehand. For this, we use the corresponding functionality built into the linnet objects in spatstat. On a standard laptop with a 1.6 GHz Intel i5 processor, the computation took only about four seconds for the largest data set, which is Ciutat Vella in summer with a total of 2494 vertices (1676 street crossings plus 818 data points). For the starting patterns in each district in summer and in winter, we chose nrandom points, where nranged from 0.8 times to 1.15 times the median cardinality of the data point patterns. Since our present implementation of the kmeansbary algorithm on graphs runs without optimDelete and optimAdd steps, we based each barycenter on a large sample of 500 starting patterns for each n. This resulted in an overall total of 101500 calls to our algorithm for the eight scenarios, which on average took 0.57 seconds each, using the precomputed distance matrices. One calculation in the largest setting (Ciutat Vella in summer) takes about 0.82 seconds and in the smallest (El Pla del Real in summer) about 0.08 seconds. The increase in the objective function was only up to 1% when decreasing the total number of calls to our algorithm by a factor of 20, resulting in a total computation time of well under one hour. Due to the choice of p=1, it happens quite frequently that there are several optimal centers for some of the clusters obtained after convergence of the kmeansbary algorithm. In this case, we take the average of their coordinates and project the result back onto the graph in order to obtain a somewhat more balanced result. The resulting point does not necessarily realize the same cluster cost as the original center points, but on a real street network it is not to be expected that the cost becomes considerably worse. In fact, for the data considered, the results hardly differed at all. 123 Statistics and Computing (2020) 30:953–972 969 Considering the barycenters in Fig. 8, it seems that there are no very clear effects of the season on the assaults. Nevertheless, we may discern a number of differences between summer and winter in the four districts, which even in this relatively small data set would be considerably harder to spot in a plot of the raw data. In the first district (Ciutat Vella), there are substantially more assaults in summer, but their spatial distribution in the barycenter is more or less similar. In Eixample, we see a concentration of assault cases in summer in the Barrio Ruzafa in the southern half of the district, whereas cases are more or less equally spread in winter. A notable feature is the occurrence of 23 barycenter points at a single crossing in summer and 7 points at the same crossing in winter with further points close by. This is due to the cul-de-sac visible in Fig. 8, which in reality forms sort of a backyard that makes the area easy for assaults, especially in summer time when there are more people (especially tourists) moving around those parts of the city. The spot is well-known to the police and in recent years the number of assaults has decreased due to police interventions. The barycenters clearly reflect this (former) assault hot spot. In the district of Extramurs, both barycenters are more or less spread over the whole district, with two clusters of assaults occurring in the east and south. Both clusters are much more pronounced in winter. In the district of El Pla del Real, there is some concentration in the winter month in the east and south-east. Apart from that the only noticeable difference is that there are substantially more assaults in winter than in summer, which may well be related to the fact that this is a popular student district. 7 Discussion and outlook In this paper, we have introduced the p-th-order TT- and RTT-metrics, which allow us to measure distances between point patterns in an intuitive way, generalizing several earlier metrics. We have investigated q-th-order barycenters with respect to the TT-metric and presented two variants of a heuristic algorithm. These variants return local minimizers of the Fréchet functional that mimic properties of the actual barycenter well and attain consistent objective function values. They are computable in a few seconds for medium-sized problems, such as 100 patterns of 100 points. For the proof of Theorem 4, it was necessary to set p=q. While such a choice may seem natural, we point out that due to the separate interpretations of pas the order for matching points in the metric on Nfin (higher ptends to balance out the matching distances) and qas the order of the empirical moment in Nfin, it may well be desirable to combine p= q. In the present paper, we have only dealt with the descriptive aspects of barycenters. It is thus clear that our applications in Sect. 6can only be seen as explorative studies. In order to determine whether differences between group barycenters are statistically significant, we need to take the distributionofthepoint patterns around theirbarycentersinto account and perform appropriate hypothesis tests. Fortunately, the Fréchet functional (7) provides us with a natural quantification of scatter around the barycenter. For q=2, it is quite common to refer to Var(ξ1,...,ξ k)=min ζ∈Nfin 1 k k  j=1 τ(ξj,ζ) 2 as (empirical) Fréchet variance, due to Equation (8). Detailed asymptotic theory for performing an analysis of variance (ANOVA) in metric spaces based on comparing Fréchet variances has been recently developed in Dubey and Müller (2019a). The application and adaptation of this theory for the point pattern space and an investigation of the performance of our heuristic algorithm in this context will be the subject of a future paper. Based on the computation of barycenters further more advanced procedures in statistics and machine learning become possible. This includes barycenter-based dimension reduction techniques, such as Wasserstein dictionary learning, see Schmitz et al. (2018), and functional principal component analysis of point patterns evolving in time, see Dubey and Müller (2019b). Acknowledgements Open Access funding provided by Projekt DEAL. Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitteduse,youwillneedtoobtainpermissiondirectlyfromthecopyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/. Appendix: Proofs left out in the main text Lemma A.1 Let C >0, C∈(0,2C]and let (X,d)be a metric space with diam(X)=supx,y∈Xd(x,y)≤2C. For k∈Nset X=X∪{ℵ1,...,ℵk}, where ℵ1,...ℵk/∈Xare pairwise different, and define d(x,y)= ⎧ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎩ d(x,y)if x,y∈X; Cif{x,y}∩X=∅ and {x,y}∩{ℵ 1,...,ℵk} =∅;  Cif{x,y}⊂{ℵ 1,...,ℵk}and x = y; 0if x =y=ℵ ifor some i ∈[k]. 123 970 Statistics and Computing (2020) 30:953–972 Then, (X,d)is a metric space. Proof Identity and symmetry properties of the map d:X× X→R+follow immediately. Since disametriconXand ˜ d(x,y)= Cif x= y(and 0 otherwise) defines a metric ˜ don Y={ℵ 1,...,ℵk}, we only have to check the triangle inequalityfor afew specialcases.If x∈Xand y∈Y(orvice versa), then d(x,y)=C. Since one of d(x,z)and d(z,y) has to be =Cregardless of z∈X, we obtain d(x,y)≤ d(x,z)+d(z,y).Ifx,y∈Xand z∈Y, then d(x,y)≤diam(X)≤2C=d(x,z)+d(z,y). Likewise, if x,y∈Yand z∈X, then d(x,y)≤ C≤2C=d(x,z)+d(z,y).  Proof of Theorem 1Since ¯τ(ξ,η) =1 n1/pτ(ξ,η), it is enough to show the statement for τ. Let π∈Snbe a permutation that minimizes n i=1d(xi,yπ(i))p. Writing I=i∈[m]; d(xi,yπ(i))< 21/pC, we obtain d(xi,yπ(i))=⎧ ⎪ ⎨ ⎪ ⎩ d(xi,yπ(i))if i∈I; 21/pCif i∈[m]\I; Cif i∈[n]\[m]. (A.15) Therefore, enumerating Iin arbitrary order as {i1,...,il}for some l∈[m]and setting jr:= π(ir)for r∈[l],wehave n  i=1 d(xi,yπ(i))p = l  r=1 d(xir,yjr)p+(m−l)(21/pC)p+(n−m)Cp =(m+n−2l)Cp+ l  r=1 d(xir,yjr)p.(A.16) Thus, τ(ξ,η)p≤minπ∈Snn i=1d(xi,yπ(i))p. Conversely, let (i1,...,il;j1,..., jl)∈S(m,n)minimize (m+n−2l)Cp+l r=1d(xir,yjr)p. This implies d(xir,yjr)≤21/pCfor all r∈[l], because otherwise we could obtain a smaller value by removing ir,jrfrom the vector. Writing I={i1,...,il},J={j1,..., jl}it implies also that d(xi,yj)≥21/pCfor all i∈[m]\Iand j∈[n]\J, because otherwise we could obtain a smaller value by adding i,jto the vector. Let then π∈Snbe any permutation satisfying π(ir)=π(jr)for all r∈[l]. With this π, we obtain exactly the d-distances in (A.15) for all i∈[n]and hence (A.16) holds again. Thus, minπ∈Snn i=1d(xi,yπ(i))p≤ τ(ξ,η)p. Proof of Theorem 2We start with the map τ:Nfin ×Nfin → R+.Ifξ=η, then m=nand there is a permutation π∈Snsuch that xi=yπ(i)for 1 ≤i≤n. Hence τ(ξ,η) =0, choosing l=nand (i1,...,il;j1,..., jl)= (1,...,n,π(1),...,π(n)). If on the other hand τ(ξ,η) =0, we must havel=m=nto be able to achieve m+n−2l=0 andtheremustbe (i1,...,in;j1,..., jn)∈S(n,n)suchthat d(xir,yjr)=0for1≤r≤n. Since the dis a metric, this yields ξ=n r=1δir=n r=1δjr=η. The symmetry of τ is immediately clear from the symmetric form of (2). For the proof of the triangle inequality, we use the metric space (X,d)introduced before Theorem 1.Letξ,η,ζ ∈ Nfin. After filling up patterns to the maximum of the three cardinalities by adding points at the auxiliary location ℵ,we may assume that ξ=n i=1δxi,η=n j=1δyjand ζ= n k=1δzkhave the same cardinality. Noting that given two pointpatternsofthesamecardinalitywemayaddanynumber of extra points located at ℵto both of them without changing their τ-distance, Theorem 1yields that there are π1,π 2∈Sn such that τ(ξ,ζ) =n  i=1 d(xi,zπ1(i))p1/p and τ(ζ,η) =n  i=1 d(zi,yπ2(i))p1/p . Then, π=π2◦π1∈Snmatches the points of ξand ηin such a way that d(xi,yπ(i))≤d(xi,zπ1(i))+d(zπ1(i),yπ2(π1(i))) and Theorem 1and the triangle inequality for the p-norm yields that τ(ξ,η) ≤n  i=1 d(xi,yπ(i))p1/p ≤n  i=1 d(xi,zπ1(i))p1/p +n  i=1 d(zπ1(i),yπ2(π1(i)))p1/p =τ(ξ,ζ)+τ(ζ,η). We turn to the map ¯τ:Nfin ×Nfin →R+. Since ¯τ(ξ,η) =1 max{|ξ|,|η|}1/pτ(ξ,η), we may inherit the identity and symmetry properties for ¯τdirectly from τ.Toshow the triangle inequality, let ξ=m1 i=1δxi,η=m2 j=1δyj and ζ=n k=1δzkbe in Nfin and set m∗=max{m1,m2}. If n≤m∗, we obtain the desired result from the triangle 123 Statistics and Computing (2020) 30:953–972 971 inequality of τas ¯τ(ξ,η) =1 m1/p ∗ τ(ξ,η) ≤1 m1/p ∗τ(ξ,ζ)+τ(ζ,η) ≤1 max{m1,n}1/pτ(ξ,ζ)+1 max{n,m2}1/pτ(ζ,η) ≤¯τ(ξ,ζ)+¯τ(ζ,η). If n>m∗, we use a slightly different construction for the extended metric space. Let X=X∪{ℵ,ℵ}for two different ℵ,ℵ/∈X. Setting d(x,y)= ⎧ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎩ min{d(x,y), 21/pC}if x,y∈X, Cif {x,y}∩X=∅and {x,y}∩{ℵ,ℵ} =∅, 21/pCif {x,y}={ℵ,ℵ}, 0ifx=y=ℵ or x=y=ℵ , weobtainby LemmaA.1that(X,d)isagainametricspace. Setting xi=ℵfor m1+1≤i≤nand yj=ℵ for m2+1≤ j≤n, we may define ˜ ξ=n i=1δxiand ˜η=n j=1δyj. Note that an optimal permutation π∗∈Sm∗for ¯τ(ξ,η) can beextendedto anoptimal permutation ˜π∗∈Snfor ¯τ(˜ ξ, ˜η) by setting ˜π∗(i)=ifor m∗+1≤i≤n. Furthermore, for any s,c≥0 with s≤m∗c,wehave 1 m∗s≤1 ns+(n−m∗)c. Combining these two facts, we obtain ¯τ(ξ,η)p=1 m∗ m∗  i=1 d(xi,yπ∗(i))p ≤1 nm∗  i=1 d(xi,yπ∗(i))p+(n−m∗)·2Cp =¯τ(˜ ξ, ˜η)p, and therefore ¯τ(ξ,η) ≤¯τ(˜ ξ, ˜η) ≤¯τ(˜ ξ,ζ)+¯τ(ζ, ˜η) =¯τ(ξ,ζ)+¯τ(ζ,η), where the second inequality holds since the cardinalities of all point patterns are equal and the equality holds by two more applications of Theorem 1. Proof of Theorem 3The equivalence for (a) was already used in Diez et al. (2012). We give a quick argument for the sake of completeness. We may assume without loss of generality that, in an admissible path P=(ξ0,...,ξN)for the minimization problem (4), •only moves from x∈ξto y∈ηoccur; •only points y∈ηare added; •only points x∈ξare deleted; because if any of these conditions were violated, the total cost of the path could only become larger (for the first item we use the triangle inequality for d). The minimization (4)is then equivalent to choosing l∈{0,1,...,min{m,n}} points to be moved from ξ-points with indices i1,...,il∈[m]to η-points with indices j1,..., jl∈[n], respectively, at cost d(xir,yjr)for each move. The remaining m−lpoints of ξare deleted at cost Cper deletion, and the remaining n−lpoints of ηare added at cost Cper addition. This yields exactly the minimization problem (2). The equivalence (b) is an immediate consequence of Theorem 1. References Agueh, M., Carlier, G.: Barycenters in the Wasserstein space. SIAM J. Math. Anal. 43, 904–924 (2011) Anderes, E., Borgwardt, S., Miller, J.: Discrete Wasserstein barycenters: optimal transport for discrete data. Math. Methods Oper. Res. 84(2), 389–409 (2016) Baddeley, A., Rubak, E., Turner, R.: Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC, Boca Raton (2015) Bandelt, H.-J., Crama, Y., Spieksma, F.C.R.: Approximation algorithms for multi-dimensional assignment problems with decomposable costs. Discrete Appl. Math. 49, 25–50 (1994) Bertsekas, D.P.: The auction algorithm: a distributed relaxation method for the assignment problem. Ann. Oper. Res. 14, 105–123 (1988) Błaszczyszyn, B., Haenggi, M., Keeler, P., Mukherjee, S.: Stochastic Geometry Analysis of Cellular Networks. Cambridge University Press, Cambridge (2018) Borgwardt, S.: An LP-based, strongly polynomial 2-approximation algorithm for sparse Wasserstein barycenters. Preprint (2019). arXiv:1704.05491v5 Borgwardt, S., Patterson, S.: Improved linear programs for discrete barycenters. INFORMS J Optim (2018). arXiv:1803.11313 Chiaraviglio, L., Cuomo, F., Maisto, M., Gigli, A., Lorincz, J., Zhou, Y., Zhao, Z., Qi, C., Zhang, H.: What is the best spatial distribution to model base station density? A deep dive into two European mobile networks. IEEE Access 4, 1434–1443 (2016) Chizat, L.: Unbalanced Optimal Transport: Models, Numerical Methods, Applications. Ph.D. thesis, PSL Research University (2017) Chizat, L., Peyré, G., Schmitzer, B., Vialard, F.-X.: Scaling algorithms for unbalanced optimal transport problems. Math. Comput. 87(314), 2563–2609 (2018) Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. MIT Press, Cambridge (2009) Cuturi,M.,Doucet,A.:FastcomputationofWassersteinbarycenters.In: Xing, E.P., Jebara, T. (eds.) Proceedings of the 31st International Conference on Machine Learning, pp. 685–693 (2014) del Barrio, E., Cuesta-Albertos, J.A., Matrán, C., Mayo-Íscar, A.: Robustclusteringtoolsbasedonoptimaltransportation.Stat.Comput. 29, 139–160 (2019) Diez, D.M., Schoenberg, F.P., Woody, C.D.: Algorithms for computing spike time distance and point process prototypes with application to feline neuronal responses to acoustic stimuli. J. Neurosci. Methods 203(1), 186–192 (2012) 123 972 Statistics and Computing (2020) 30:953–972 Diggle, P.J.: Statistical Analysis of Spatial and Spatio-Temporal Point Patterns. Chapman and Hall/CRC, Boca Raton (2013) Dubey, P., Müller, H.-G.: Fréchet analysis of variance for random objects. Preprint 106(4), 803–821 (2019a) Dubey, P., Müller, H.-G.: Functional models for time-varying random objects. Preprint (2019b). arXiv:1907.10829 Fréchet, M.: Les éléments aléatoires de nature quelconque dans un espace distancié. Ann. Inst. H. Poincaré 10, 215–310 (1948) Hakimi, S.L.: Optimum locations of switching centers and the absolute centers and medians of a graph. Oper. Res. 12(3), 456–458 (1964) Koliander, G., Schuhmacher, D., Hlawatsch, F.: Rate-distortion theory of finite point processes. IEEE Trans. Inf. Theory 64(8), 5832– 5861 (2018) Konstantinoudis, G., Schuhmacher, D., Ammann, R., Diesch, T., Kuehni, C., Spycher, B.D.: Bayesian spatial modelling of childhood cancer incidence in Switzerland using exact point data: a nationwide study during 1985–2015. Preprint (2019). https:// www.medrxiv.org/content/early/2019/07/15/19001545 Kuhn, H.W.: The Hungarian method for the assignment problem. Naval Res. Logist. Quart. 2, 83–97 (1955) Liero, M., Mielke, A., Savaré, G.: Optimal entropy-transport problems and a new Hellinger-Kantorovich distance between positive measures. Invent. Math. 211(3), 969–1117 (2018) Lin, Z., Müller, H.-G.: Total variation regularized Fréchet regression for metric-space valued data. Preprint (2019). arXiv:1904.09647 Lombardo, L., Opitz, T., Huser, R.: Point process-based modeling of multiple debris flow landslides using INLA: an application to the 2009 Messina disaster. Stoch. Environ. Res Risk Assess. 32(7), 2179–2198 (2018) Luenberger, D.G., Ye, Y.: Linear and Nonlinear Programming, third edn. Springer, New York (2008) Mateu, J., Schoenberg, F.P., Diez, D.M., Gonzáles, J.A., Lu, W.: On measures of dissimilarity between point patterns: classification based on prototypes and multidimensional scaling. Biom. J. 57(2), 340–358 (2015) Moradi, M., Mateu, J.: First and second-order characteristics of spatiotemporal point processes on linear networks. J. Comput. Graph. Stat. (2019, to appear) Moradi, M., Rodriguez-Cortes, F., Mateu, J.: On kernel-based intensity estimation of spatial point patterns on linear networks. J. Comput. Graph. Stat. 27(2), 302–311 (2018) Müller, R., Schuhmacher, D.: ttbary: barycenter methods for spatial point patterns. Rpackage version 0.1-1. (2019) https://cran. r-project.org/package=ttbary Petersen, A., Müller, H.-G.: Fréchet regression for random objects with Euclidean predictors. Ann. Stat. 47(2), 691–719 (2019) Peyré, G., Cuturi, M.: Computational optimal transport Foundations and Trends®. Mach. Learn. 11(5–6), 355–607 (2019) R Core Team: R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria (2019) Rakshit, S., Davies, T., Moradi, M., McSwiggan, G., Nair, G., Mateu, J., Baddeley, A.: Fast kernel smoothing of point patterns on a large network using 2d convolution. Int. Stat. Rev. (2019) Samartsidis, P., Eickhoff, C.R., Eickhoff, S.B., Wager, T.D., Barrett, L.F.,Atzil,S.,Johnson,T.D.,Nichols,T.E.: Bayesianlog-Gaussian Cox process regression: applications to meta-analysis of neuroimaging working memory studies. J. R. Stat. Soc. Ser. C 68(1), 217–234 (2019) Schmitz,M.A.,Heitz,M.,Bonneel,N.,Ngole,F.,Coeurjolly,D.,Cuturi, M., Peyré, G., Starck, J.-L.: Wasserstein dictionary learning: optimal transport-based unsupervised nonlinear dictionary learning. SIAM J. Imaging Sci. 11(1), 643–678 (2018) Schoenberg, F.P., Tranbarger, K.E.: Description of earthquake aftershock sequences using prototype point patterns. Environmetrics 19(3), 271–286 (2008) Schuhmacher, D.: Stein’s method for approximating complex distributions, with a view towards point processes. In: Schmidt, V. (ed.) Stochastic Geometry, Spatial Statistics and Random Fields, Vol. II: Models and Algorithms. Lecture Notes in Mathematics, vol. 2120, pp. 1–30. Springer (2014) Schuhmacher, D., Vo, B.-T., Vo, B.-N.: A consistent metric for performance evaluation of multi-object filters. IEEE Trans. Signal Process. 56(8, part 1), 3447–3457 (2008) Schuhmacher, D., Xia, A.: A new metric between distributions of point processes. Adv. Appl. Probab. 40(3), 651–672 (2008) Victor, J.D., Purpura, K.P.: Metric-space analysis of spike trains: theory, algorithmsandapplication.Netw.ComputNeuralSyst.8,127–164 (1997) Weiszfeld, E.: Sur le point pour lequel la somme des distances de n points donnés est minimum. Tohoku Math. J. 43, 355–386 (1937) Publisher’s Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. 123