ott.geometry.distrib_costs.UnivariateWasserstein#
- class ott.geometry.distrib_costs.UnivariateWasserstein(solve_fn, ground_cost=None)[source]#
1D Wasserstein cost for two 1D distributions.
This ground cost between considers vectors as a family of values. The Wasserstein distance between them is the 1D OT cost, using a user-defined ground cost.
- Parameters:
solve_fn (
Callable
[[LinearProblem
],UnivariateOutput
]) – 1D optimal transport solver, e.g.,uniform_distance()
.ground_cost (
Optional
[TICost
]) – Cost used to compute the 1D optimal transport between vectors. Should be a translation-invariant (TI) cost for correctness. IfNone
, defaults toSqEuclidean
.
Methods
all_pairs
(x, y)Compute matrix of all pairwise costs, including the
norms
.barycenter
(weights, xs)Barycentric operator.
twist_operator
(vec, dual_vec, variable)Twist inverse operator of the cost function.