class ott.geometry.costs.CostFn[source]#

Base class for all costs.

Cost functions evaluate a function on a pair of inputs. For convenience, that function is split into two norms – evaluated on each input separately – followed by a pairwise cost that involves both inputs, as in:

\[c(x,y) = norm(x) + norm(y) + pairwise(x,y)\]

If the norm function is not implemented, that value is handled as \(0\), and only pairwise() is used.


all_pairs(x, y)

Compute matrix of all pairwise costs, including the norms.

all_pairs_pairwise(x, y)

Compute matrix of all pairwise costs, excluding the norms.

barycenter(weights, xs)

Barycentric operator.

pairwise(x, y)

Compute cost between \(x\) and \(y\).