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. Withmethod="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 whenChas few columns.
- l2_min_enclosing_ball(C: ndarray) Tuple[float, ndarray]¶
The smallest Euclidean ball containing the rows of
C. Returns(radius, center). Onlydoubleis 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 eithermethod="lp"ormethod="linf"(an embedding in \(\ell_\infty\), as inl1_diameter()). Ifin_conv_hullis 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
pion the probability simplex, that is the distribution closest topiin \(\ell_2\) distance.