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]

Given a set of input points with primary property x and secondary property y, and a mapping between that primary property and another secondary property (y2 | x2), assign values of the y2 property to the input points.

The y2 that is assigned (ynew) is in monotonic correspondence with y at fixed x. Therefore, \(P(<y_{\rm new} | x) = P(<y | x)\).

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

Parameters:
xndarray

Numpy array of shape (n1, ) storing the primary property of the input points.

yndarray

Numpy array of shape (n1, ) storing the secondary property of the input points.

x2ndarray

Numpy array of shape (n2, ) storing the primary property of the desired distribution. This should be the same physical property (e.g. halo mass) as x.

y2ndarray

Numpy array of shape (n2, ) storing the secondary property of the desired distribution. This is a different physical property to y.

nwinint

Odd integer specifying the size of the window used to estimate \(P(<y | x)\). See Notes.

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 nwin. This argument can be important for eliminating artificial discreteness effects. Default is True.

assume_x_is_sortedbool, optional

Performance enhancement flag that can be used for cases where input x and y have been pre-sorted so that x is monotonically increasing. Default is False.

assume_x2_is_sortedbool, optional

Performance enhancement flag that can be used for cases where input x2 and y2 have been pre-sorted so that x2 is monotonically increasing. Default is False.

return_indexesbool, 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:
ynewndarray

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 sub-percent accuracy, values of window_length must exceed 100. Values more tha a few hundred are likely overkill when using the (recommended) sub-grid noise option.

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)