pyuncertainnumber.calibration.data_peeling.peeling ================================================== .. py:module:: pyuncertainnumber.calibration.data_peeling.peeling Functions --------- .. autoapisummary:: pyuncertainnumber.calibration.data_peeling.peeling.data_peeling_algorithm pyuncertainnumber.calibration.data_peeling.peeling.index_to_mask pyuncertainnumber.calibration.data_peeling.peeling.make_hashtable pyuncertainnumber.calibration.data_peeling.peeling.sanity_check pyuncertainnumber.calibration.data_peeling.peeling.data_peeling_backward pyuncertainnumber.calibration.data_peeling.peeling.extract_kn pyuncertainnumber.calibration.data_peeling.peeling.peeling_to_structure pyuncertainnumber.calibration.data_peeling.peeling.uniform pyuncertainnumber.calibration.data_peeling.peeling.samples_to_structure pyuncertainnumber.calibration.data_peeling.peeling.width Module Contents --------------- .. py:function:: data_peeling_algorithm(X: numpy.typing.NDArray, tol: float = 0.0001) -> tuple[list, list] Data peeling algorithm for constructing a sequence of nested enclosing sets. :param X: data set of iid observations :type X: NDArray :param tol: a tolerance parameter determining the minimal size of an allowed enclosing box :type tol: float :returns: a tuple containing: - sequence_of_indices (list): a list (number of levels long) of sets (or list) of indices of heterogeneous size - sequence_of_boxes (list): a list (number of levels long) of (dx2) boxes :rtype: tuple[list, list] .. figure:: /_static/peeling_illus.png :alt: ks_bounds :align: center :width: 90% Illustration of the data peeling algorithm. .. py:function:: index_to_mask(x: list, n=100) -> numpy.ndarray Converts the list of indices x into a (nx1) boolean mask, true at those particular indices :param x: list of indices :type x: list :param n: size of the mask. Defaults to 100. :type n: int, optional :returns: boolean mask :rtype: numpy.ndarray .. py:function:: make_hashtable(x) .. py:function:: sanity_check(a, b, tol=0.0001) .. py:function:: data_peeling_backward(uy: numpy.typing.NDArray, y: numpy.typing.NDArray = None, boxes: list = None, tol=0.0001) -> tuple[list, list, list] :param uy: (mxd) array of coverage samples output space. :type uy: NDArray :param boxes: sequence of boxes, each box is a (dx2) array. Also iterable of interval objects. :type boxes: list :returns: a tuple containing: - a: list (number of levels long) of sets (or list) of indices (heterogeneous size). - b: list (number of levels long) of (dx2) boxes (array-like). - c: list (number of levels long) of indices (input space) conatained in each level. :rtype: tuple[list, list, list] .. note:: There are two cases where the peeling algorithm must raise an exception, and they are both linked to the termination of the algorithm. - When the last enclosing set has less samples than the minimum number of support scenarios to determine that set. - When there are enough samples to determine the set but some of them are too close to eachother (even for just one dimension). While two may be linked to the problem of degeneracy, in this context, it may be best suited to refer to this case as a coverage problem. .. py:function:: extract_kn(a) .. py:function:: peeling_to_structure(a: list, b: list, kind: str = 'scenario', beta: float = 0.01) -> tuple[numpy.typing.NDArray, list] Peeling to structure. :param a: (number of levels long) of sets (or list) of indices of heterogeneous size :type a: list :param b: (number of levels long) of (dx2) boxes (array-like) :type b: list :returns: (lxdx2) array containing the projections of a joint fuzzy number. p: list[float] of length l :rtype: f .. note:: Note b may not be boxes, but spheres, ellipses, etc. .. tip:: keep b for piping: peeling_to_structure(data_peeling_algorithm(x)) .. py:function:: uniform(lo, hi, N=100) .. py:function:: samples_to_structure(ux: numpy.typing.NDArray, c: list) :param ux: (mxd_) array. :type ux: NDArray :param c: (number of levels long) subset of indices (input space) conatained in each level. :type c: list :returns: (lxd_x2) array containing the projections of a joint fuzzy number in the input space. :rtype: fx .. py:function:: width(x: numpy.typing.NDArray) :param x: An interval or interval iterable, i.e. an (dx2) array :returns: the width of the intervals :rtype: w