def hist_quantiles(hist, prob=(<NUM_LIT>, <NUM_LIT>), return_indices=False, copy=True):
<EOL>hist_t = np.array(hist)<EOL>cdf = np.cumsum(hist_t)<EOL>if cdf[-<NUM_LIT:1>] == <NUM_LIT:0>:<EOL><INDENT>normcdf = cdf.astype('<STR_LIT:float>')<EOL><DEDENT>else:<EOL><INDENT>normcdf = cdf.astype('<STR_LIT:float>') / cdf[-<NUM_LIT:1>]<EOL><DEDENT>unormcdf, indices = np.unique(normcdf, return_index=True)<EOL>try:<EOL><INDENT>hp = np.where(unormcdf > prob[<NUM_LIT:1>])[<NUM_LIT:0>][<NUM_LIT:0>]<EOL>lp = np.where(unormcdf >= prob[<NUM_LIT:0>])[<NUM_LIT:0>][<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>hp_index = hist_t.shape[<NUM_LIT:0>]<EOL>lp_index = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>hp_index = indices[hp]<EOL>lp_index = indices[lp]<EOL><DEDENT>masked_hist = np.ma.array(hist, copy=copy, mask=True)<EOL>masked_hist.mask[lp_index:hp_index + <NUM_LIT:1>] = False<EOL>if return_indices:<EOL><INDENT>return masked_hist, (lp_index, hp_index)<EOL><DEDENT>else:<EOL><INDENT>return masked_hist<EOL><DEDENT>
Calculate quantiles from histograms, cuts off hist below and above given quantile. This function will not cut off more than the given values.

    Parameters
    ----------
    hist : array_like, iterable
        Input histogram with dimension at most 1.
    prob : float, list, tuple
        List of quantiles to compute. Upper and lower limit. From 0 to 1. Default is 0.05 and 0.95.
    return_indices : bool, optional
        If true, return the indices of the hist.
    copy : bool, optional
        Whether to copy the input data (True), or to use a reference instead. Default is False.

    Returns
    -------
    masked_hist : masked_array
       Hist with masked elements.
    masked_hist : masked_array, tuple
        Hist with masked elements and indices.