@docsubst<EOL><INDENT>def limits_percentage(self, expression, percentage=<NUM_LIT>, square=False, delay=False):<DEDENT>
<EOL>import scipy<EOL>logger.info("<STR_LIT>", expression, percentage)<EOL>waslist, [expressions, ] = vaex.utils.listify(expression)<EOL>limits = []<EOL>for expr in expressions:<EOL><INDENT>subspace = self(expr)<EOL>limits_minmax = subspace.minmax()<EOL>vmin, vmax = limits_minmax[<NUM_LIT:0>]<EOL>size = <NUM_LIT> * <NUM_LIT:16><EOL>counts = subspace.histogram(size=size, limits=limits_minmax)<EOL>cumcounts = np.concatenate([[<NUM_LIT:0>], np.cumsum(counts)])<EOL>cumcounts /= cumcounts.max()<EOL>f = (<NUM_LIT:1> - percentage / <NUM_LIT>) / <NUM_LIT:2><EOL>x = np.linspace(vmin, vmax, size + <NUM_LIT:1>)<EOL>l = scipy.interp([f, <NUM_LIT:1> - f], cumcounts, x)<EOL>limits.append(l)<EOL><DEDENT>return vaex.utils.unlistify(waslist, limits)<EOL>
Calculate the [min, max] range for expression, containing approximately a percentage of the data as defined
        by percentage.

        The range is symmetric around the median, i.e., for a percentage of 90, this gives the same results as:

        Example:

        >>> df.limits_percentage("x", 90)
        array([-12.35081376,  12.14858052]
        >>> df.percentile_approx("x", 5), df.percentile_approx("x", 95)
        (array([-12.36813152]), array([ 12.13275818]))

        NOTE: this value is approximated by calculating the cumulative distribution on a grid.
        NOTE 2: The values above are not exactly the same, since percentile and limits_percentage do not share the same code

        :param expression: {expression_limits}
        :param float percentage: Value between 0 and 100
        :param delay: {delay}
        :return: {return_limits}