BarcodeDistance

org.appliedtopology.tda4j.BarcodeDistance

Bottleneck and Wasserstein distances between persistence diagrams, by bipartite matching where each point may also be matched to its projection on the diagonal.

The parameters follow GUDHI and Hera: groundNorm (their internal_p) measures one matched pair in the birth-death plane; order (their order, q in Kerber-Morozov-Nigmetov 2017) is the exponent the costs of all pairs are combined with. Wasserstein distance tends to bottleneck distance as order -> Infinity; use bottleneckDistance for that case.

'''Essential bars''' are matched only to essential bars, in order of birth (which is optimal for both distances). If the diagrams have different numbers of essential bars, the distance is Infinity.

Attributes

Experimental
true
Source
BarcodeDistance.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

enum GroundNorm

The norm on the birth-death plane that measures one matched pair (GUDHI and Hera's internal_p). LInfinity, the default there and here, is the usual choice.

The norm on the birth-death plane that measures one matched pair (GUDHI and Hera's internal_p). LInfinity, the default there and here, is the usual choice.

Attributes

Source
BarcodeDistance.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Matching(pairs: Vector[(Int, Int)], leftToDiagonal: Vector[Int], rightToDiagonal: Vector[Int], cost: Double)

An optimal matching of two diagrams: bar i of the first diagram is matched to bar j of the second for each (i, j) of pairs; the bars in leftToDiagonal and rightToDiagonal (indices into the diagrams as given) are matched to the diagonal, that is, left unmatched; cost is the distance the matching realizes.

An optimal matching of two diagrams: bar i of the first diagram is matched to bar j of the second for each (i, j) of pairs; the bars in leftToDiagonal and rightToDiagonal (indices into the diagrams as given) are matched to the diagonal, that is, left unmatched; cost is the distance the matching realizes.

Attributes

Source
BarcodeDistance.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def bottleneckDistance(diagram1: Seq[PersistenceBar[Double, _]], diagram2: Seq[PersistenceBar[Double, _]], groundNorm: GroundNorm = ...): Double

Bottleneck distance between two persistence diagrams of a single homological dimension. diagram1/ diagram2 must each be internally homogeneous in .dim (a mismatch usually means an unfiltered multi-dimensional barcode was passed by mistake -- use bottleneckDistanceByDimension for that case); the two diagrams' own dimensions are not required to agree with each other, since asking that question directly (rather than through bottleneckDistanceByDimension) is treated as a deliberate choice, not a mistake to guard against. See the class doc for the essential-bar policy and the ground-metric/aggregation convention.

Bottleneck distance between two persistence diagrams of a single homological dimension. diagram1/ diagram2 must each be internally homogeneous in .dim (a mismatch usually means an unfiltered multi-dimensional barcode was passed by mistake -- use bottleneckDistanceByDimension for that case); the two diagrams' own dimensions are not required to agree with each other, since asking that question directly (rather than through bottleneckDistanceByDimension) is treated as a deliberate choice, not a mistake to guard against. See the class doc for the essential-bar policy and the ground-metric/aggregation convention.

Attributes

Source
BarcodeDistance.scala
def bottleneckDistanceByDimension(diagram1: Seq[PersistenceBar[Double, _]], diagram2: Seq[PersistenceBar[Double, _]], groundNorm: GroundNorm = ...): Map[Int, Double]

Convenience wrapper: groups two (possibly multi-dimensional) barcodes by .dim and computes bottleneckDistance within each dimension present in either one (a dimension missing from one side is treated as the empty diagram on that side, i.e. every bar on the other side must die to the diagonal, or the comparison is Infinity if any of them is essential).

Convenience wrapper: groups two (possibly multi-dimensional) barcodes by .dim and computes bottleneckDistance within each dimension present in either one (a dimension missing from one side is treated as the empty diagram on that side, i.e. every bar on the other side must die to the diagonal, or the comparison is Infinity if any of them is essential).

Attributes

Source
BarcodeDistance.scala
def bottleneckMatching(diagram1: Seq[PersistenceBar[Double, _]], diagram2: Seq[PersistenceBar[Double, _]], groundNorm: GroundNorm = ...): Option[Matching]

A matching that realizes bottleneckDistance of the same arguments (None when the numbers of essential bars differ). It is a perfect matching of the augmented graph that keeps the pairs within the bottleneck distance, found by Hopcroft-Karp, so it takes quadratic space in the number of bars; it is one of many optimal matchings.

A matching that realizes bottleneckDistance of the same arguments (None when the numbers of essential bars differ). It is a perfect matching of the augmented graph that keeps the pairs within the bottleneck distance, found by Hopcroft-Karp, so it takes quadratic space in the number of bars; it is one of many optimal matchings.

Attributes

Source
BarcodeDistance.scala
def slicedWassersteinDistance(diagram1: Seq[PersistenceBar[Double, _]], diagram2: Seq[PersistenceBar[Double, _]], directions: Int = ...): Double

The sliced Wasserstein distance between two persistence diagrams (Carriere, Cuturi, Oudot 2017): project both diagrams, each completed by the orthogonal projections of the other's points onto the diagonal, onto a line, compare the sorted projections in L1, and average over the lines. It is a metric on diagrams that is bounded by constant multiples of the 1-Wasserstein distance and costs O(directions * n log n), so it suits kernels and large diagrams, where the Hungarian algorithm does not.

The sliced Wasserstein distance between two persistence diagrams (Carriere, Cuturi, Oudot 2017): project both diagrams, each completed by the orthogonal projections of the other's points onto the diagonal, onto a line, compare the sorted projections in L1, and average over the lines. It is a metric on diagrams that is bounded by constant multiples of the 1-Wasserstein distance and costs O(directions * n log n), so it suits kernels and large diagrams, where the Hungarian algorithm does not.

The average runs over directions evenly-spaced angles in [-pi/2, pi/2). The distance between a diagram of one bar and the empty diagram tends to persistence * sqrt(2) / pi as directions grows (the spec checks it). Essential bars are dropped; compare them with bottleneckDistance.

Attributes

Source
BarcodeDistance.scala
def wassersteinDistance(diagram1: Seq[PersistenceBar[Double, _]], diagram2: Seq[PersistenceBar[Double, _]], order: Double = ..., groundNorm: GroundNorm = ...): Double

The Wasserstein distance of order order (finite, at least 1.0) between the diagrams of one homological dimension, essential bars handled as in bottleneckDistance.

The Wasserstein distance of order order (finite, at least 1.0) between the diagrams of one homological dimension, essential bars handled as in bottleneckDistance.

Attributes

Source
BarcodeDistance.scala
def wassersteinDistanceByDimension(diagram1: Seq[PersistenceBar[Double, _]], diagram2: Seq[PersistenceBar[Double, _]], order: Double = ..., groundNorm: GroundNorm = ...): Map[Int, Double]
def wassersteinMatching(diagram1: Seq[PersistenceBar[Double, _]], diagram2: Seq[PersistenceBar[Double, _]], order: Double = ..., groundNorm: GroundNorm = ...): Option[Matching]

A matching that realizes wassersteinDistance of the same arguments (None when the diagrams have different numbers of essential bars, where the distance is Infinity and no matching exists). Essential bars are matched in order of birth. The finite bars are matched by the Hungarian algorithm on the augmented cost matrix, so the cost is quadratic in the number of bars in space and cubic in time; for large diagrams use slicedWassersteinDistance.

A matching that realizes wassersteinDistance of the same arguments (None when the diagrams have different numbers of essential bars, where the distance is Infinity and no matching exists). Essential bars are matched in order of birth. The finite bars are matched by the Hungarian algorithm on the augmented cost matrix, so the cost is quadratic in the number of bars in space and cubic in time; for large diagrams use slicedWassersteinDistance.

Attributes

Source
BarcodeDistance.scala