halotools.utils.sliding_conditional_percentile(x, y, window_length, assume_x_is_sorted=False, add_subgrid_noise=True, seed=None)[source]

Estimate the cumulative distribution function Prob(< y | x).


Array of shape (npts, )


Array of shape (npts, )


Integer must be odd and less than npts

assume_x_is_sortedbool, optional

Performance enhancement flag that can be used for cases where input x has already been sorted. Default is False.

add_subgrid_noisebool, optional

Flag determines whether random uniform noise will be added to fill in the gaps at the sub-grid level determined by window_length. Default is True.

seedint, optional

Random number seed used together with the add_subgrid_noise argument to minimize discreteness effects due to the finite window size over which Prob(< y | x) is estimated. Default is None, for stochastic results.


Numpy array of shape (npts, ) storing values in the open interval (0, 1). Larger values of the returned array correspond to values of y that are larger-than-average for the corresponding value of x.


The window_length argument controls the precision of the calculation, and also the performance. For estimations of Prob(< y | x) with sub-percent accuracy, values of window_length must exceed 100.

See Tutorial on Conditional Abundance Matching demonstrating how to use this function in galaxy-halo modeling with several worked examples.


>>> x = np.random.rand(100)
>>> y = np.random.rand(100)
>>> window_length = 5
>>> result = sliding_conditional_percentile(x, y, window_length)