Metric optimization problems

qif.metric.optimize

Functions

l1_diameter(C: ndarray, method: str = 'direct') → Tuple[FloatOrRat, int, int]

The \(\ell_1\) diameter of the rows of C: the maximum \(\lVert C_{x,-} - C_{x',-}\rVert_1\). Returns (diameter, x, x') with the two rows achieving it. With method="direct" all pairs of rows are compared; method="linf" embeds the rows in \(\ell_\infty\) of dimension \(2^m\) (\(m\) the number of columns), faster when C has few columns.

l2_min_enclosing_ball(C: ndarray) → Tuple[float, ndarray]

The smallest Euclidean ball containing the rows of C. Returns (radius, center). Only double is supported.

simplex_l1_min_enclosing_ball(C: ndarray, method: str = 'lp', in_conv_hull: bool = False) → Tuple[FloatOrRat, ndarray]

The distribution \(q\) minimizing the maximum \(\ell_1\) distance \(\lVert C_{x,-} - q\rVert_1\) from the rows of C. Returns (radius, q). Computed by linear programming, using either method="lp" or method="linf" (an embedding in \(\ell_\infty\), as in l1_diameter()). If in_conv_hull is true (only with "lp"), \(q\) is restricted to the convex hull of the rows.

simplex_project(pi: ndarray) → ndarray

The Euclidean projection of the vector pi on the probability simplex, that is the distribution closest to pi in \(\ell_2\) distance.