bayesvalidrox.surrogate_models.glexindex.cross_truncate¶
- bayesvalidrox.surrogate_models.glexindex.cross_truncate(indices, bound, norm)¶
Truncate of indices using L_p norm. .. math:
L_p(x) = sum_i |x_i/b_i|^p ^{1/p} leq 1
where \(b_i\) are bounds that each \(x_i\) should follow. Args:
- indices (Sequence[int]):
Indices to be truncated.
- bound (int, Sequence[int]):
The bound function for witch the indices can not be larger than.
- norm (float, Sequence[float]):
The p in the L_p-norm. Support includes both L_0 and L_inf.
- Returns:
Boolean indices to
indices
with True for each index where the truncation criteria holds.- Examples:
>>> indices = numpy.array(numpy.mgrid[:10, :10]).reshape(2, -1).T >>> indices[cross_truncate(indices, 2, norm=0)].T array([[0, 0, 0, 1, 2], [0, 1, 2, 0, 0]]) >>> indices[cross_truncate(indices, 2, norm=1)].T array([[0, 0, 0, 1, 1, 2], [0, 1, 2, 0, 1, 0]]) >>> indices[cross_truncate(indices, [0, 1], norm=1)].T array([[0, 0], [0, 1]])