sliding_conditional_percentile¶

halotools.utils.
sliding_conditional_percentile
(x, y, window_length, assume_x_is_sorted=False, add_subgrid_noise=True, seed=None)[source] [edit on github]¶ Estimate the cumulative distribution function Prob(< y  x).
Parameters: x : ndarray
Array of shape (npts, )
y : ndarray
Array of shape (npts, )
window_length : int
Integer must be odd and less than
npts
assume_x_is_sorted : bool, optional
Performance enhancement flag that can be used for cases where input
x
has already been sorted. Default is False.add_subgrid_noise : bool, optional
Flag determines whether random uniform noise will be added to fill in the gaps at the subgrid level determined by
window_length
. Default is True.seed : int, 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.Returns: rank_order_percentiles : ndarray
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 largerthanaverage for the corresponding value ofx
.Notes
The
window_length
argument controls the precision of the calculation, and also the performance. For estimations of Prob(< y  x) with subpercent accuracy, values ofwindow_length
must exceed 100.See Tutorial on Conditional Abundance Matching demonstrating how to use this function in galaxyhalo modeling with several worked examples.
Examples
>>> x = np.random.rand(100) >>> y = np.random.rand(100) >>> window_length = 5 >>> result = sliding_conditional_percentile(x, y, window_length)