bayesvalidrox.surrogate_models.glexindexΒΆ

Multi indices for monomial exponents. Credit: Jonathan Feinberg https://github.com/jonathf/numpoly/blob/master/numpoly/utils/glexindex.py

Functions

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]]).

glexindex(start[, stop, dimensions, ...])

Generate graded lexicographical multi-indices for the monomial exponents. Args: start (Union[int, numpy.ndarray]): The lower order of the indices. If array of int, counts as lower bound for each axis. stop (Union[int, numpy.ndarray, None]): The maximum shape included. If omitted: stop <- start; start <- 0 If int is provided, set as largest total order. If array of int, set as upper bound for each axis. dimensions (int): The number of dimensions in the expansion. cross_truncation (float, Tuple[float, float]): Use hyperbolic cross truncation scheme to reduce the number of terms in expansion. If two values are provided, first is low bound truncation, while the latter upper bound. If only one value, upper bound is assumed. graded (bool): Graded sorting, meaning the indices are always sorted by the index sum. E.g. (2, 2, 2) has a sum of 6, and will therefore be consider larger than both (3, 1, 1) and (1, 1, 3). reverse (bool): Reversed lexicographical sorting meaning that (1, 3) is considered smaller than (3, 1), instead of the opposite. Returns: list: Order list of indices. Examples: >>> numpoly.glexindex(4).tolist() [[0], [1], [2], [3]] >>> numpoly.glexindex(2, dimensions=2).tolist() [[0, 0], [1, 0], [0, 1]] >>> numpoly.glexindex(start=2, stop=3, dimensions=2).tolist() [[2, 0], [1, 1], [0, 2]] >>> numpoly.glexindex([1, 2, 3]).tolist() [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 2]] >>> numpoly.glexindex([1, 2, 3], cross_truncation=numpy.inf).tolist() [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 1, 1], [0, 0, 2], [0, 1, 2]].