This collection of functions computes the distance between two persistencediagrams of the same homology dimension. The diagrams must be represented as2-column matrices. The first column of the matrix contains the birth timesand the second column contains the death times of the points.
Arguments
- x
Either a matrix of shape \(n \times 2\) or an object of classpersistence specifying the first persistence diagram.
- y
Either a matrix of shape \(m \times 2\) or an object of classpersistence specifying the second persistence diagram.
- tol
A numeric value specifying the relative error. Defaults to
sqrt(.Machine$double.eps). For the Bottleneck distance, it can be set to0.0in which case the exact Bottleneck distance is computed, while anapproximate Bottleneck distance is computed iftol > 0.0. For theWasserstein distance, it must be strictly positive.- validate
A boolean value specifying whether to validate the inputpersistence diagrams. Defaults to
TRUE. IfFALSE, the function will notcheck if the input persistence diagrams are valid. This can be useful forperformance reasons, but it is recommended to keep itTRUEfor safety.- dimension
An integer value specifying the homology dimension for whichto compute the distance. Defaults to
0L. This is only used ifxandyare objects of classpersistence.- p
A numeric value specifying the power for the Wasserstein distance.Defaults to
1.0.
Value
A numeric value storing either the Bottleneck or the Wassersteindistance between the two persistence diagrams.
Details
A matching \(\varphi : D_1 \to D_2\) between persistence diagrams is abijection of multisets, where both diagrams are assumed to have all points onthe diagonal with infinite multiplicity. The\(p\)-Wasserstein distancebetween \(D_1\) and \(D_2\) is defined as the infimum over all matchingsof the expression
$$W_p(D_1,D_2) = \inf_{\varphi: D_1 \to D_2}\left( \sum_{x \in D_1}{\lVert x - \varphi(x) \rVert^p}\right)^{\frac{1}{p}}$$
that can be thought of as the Minkowski distance between the diagrams viewedas vectors on the shared coordinates defined by the matching \(\varphi\).The norm \(\lVert \cdot \rVert\) can be arbitrary; as implemented here, itis the infinity norm \(\lVert (x_1,x_2) \rVert_\infty = \max(x_1,x_2)\). Inthe limit \(p \to \infty\), the Wasserstein distance becomes thebottleneck distance:
$$B(D_1,D_2) = \inf_{\varphi: D_1 \to D_2}\sup_{x \in D_1}{\lVert x - \varphi(x) \rVert}.$$
The Wasserstein metric is also called the Kantorovich metric in recognitionof the originator of the metric.
Examples
bottleneck_distance(persistence_sample[[1]]$pairs[[1]],persistence_sample[[2]]$pairs[[1]])#> [1] 0.06197453bottleneck_distance(persistence_sample[[1]],persistence_sample[[2]])#> [1] 0.06197453wasserstein_distance(persistence_sample[[1]]$pairs[[1]],persistence_sample[[2]]$pairs[[1]])#> [1] 1.53403wasserstein_distance(persistence_sample[[1]],persistence_sample[[2]])#> [1] 1.53403