conditional_abunmatch¶

halotools.empirical_models.
conditional_abunmatch
(x, y, x2, y2, nwin, add_subgrid_noise=True, assume_x_is_sorted=False, assume_x2_is_sorted=False, return_indexes=False)[source] [edit on github]¶ Given a set of input points with primary property
x
and secondary propertyy
, use conditional abundance matching to map new valuesynew
onto the input points such that \(P(<y_{\rm new}  x) = P(<y_2  x)\), and also thaty
andynew
are in monotonic correspondence at fixedx
.Parameters: x : ndarray
Numpy array of shape (n1, ) storing the primary property of the input points.
y : ndarray
Numpy array of shape (n1, ) storing the secondary property of the input points.
x2 : ndarray
Numpy array of shape (n2, ) storing the primary property of the desired distribution.
y2 : ndarray
Numpy array of shape (n2, ) storing the secondary property of the desired distribution.
nwin : int
Odd integer specifying the size of the window used to estimate \(P(<y  x)\). See Notes.
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
nwin
. This argument can be important for eliminating artificial discreteness effects. Default is True.assume_x_is_sorted : bool, optional
Performance enhancement flag that can be used for cases where input
x
andy
have been presorted so thatx
is monotonically increasing. Default is False.assume_x2_is_sorted : bool, optional
Performance enhancement flag that can be used for cases where input
x2
andy2
have been presorted so thatx2
is monotonically increasing. Default is False.return_indexes : bool, optional
Return the indexes in y2 of where to find the new values, rather than the values.
add_subgrid_noise
must be set to False is this is set. Default is False.Returns: ynew : ndarray
Numpy array of shape (n1, ) storing the new values (or indexes if return_indexes is True) of the secondary property for the input points.
Notes
The
nwin
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. Values more tha a few hundred are likely overkill when using the (recommended) subgrid noise option.See Tutorial on Conditional Abundance Matching demonstrating how to use this function in galaxyhalo modeling with several worked examples.
With the release of Halotools v0.7, this function replaced a previous function of the same name. The old function is now called
conditional_abunmatch_bin_based
.Examples
>>> npts1, npts2 = 5000, 3000 >>> x = np.linspace(0, 1, npts1) >>> y = np.random.uniform(1, 1, npts1) >>> x2 = np.linspace(0.5, 0.6, npts2) >>> y2 = np.random.uniform(5, 3, npts2) >>> nwin = 51 >>> new_y = conditional_abunmatch(x, y, x2, y2, nwin)