cython_bin_free_cam_kernel¶

halotools.empirical_models.
cython_bin_free_cam_kernel
()¶ Kernel underlying the binfree implementation of conditional abundance matching. For the i^th element of y1, we define a window of length
nwin
surrounding the point y1[i], and another window surrounding y2[i2_match[i]]. We calculate the rankorder of y1[i] within the first window. Then we find the point in the second window with a matching rankorder and use this value as ynew[i]. The algorithm has been implemented so that the windows are only sorted once at the beginning, and as the windows slide along the arrays with increasing i, elements are popped in and popped out so as to preserve the sorted order.When using add_subgrid_noise, the algorithm differs slightly. Rather than setting ynew[i] to the value in the second window with the matching rankorder, instead we assign a random uniform number from the range spanned by (y2_window[rank1],y2_window[rank+1]). This reduces discreteness effects and comes at no loss of precision since the PDF is not known to an accuracy better than 1/nwin.
The arrays named sorted_cdf_values store the yvalues in the two windows. The arrays correspondence_indx are responsible for the bookkeeping involved in maintaining a sorted order as elements are popped in and popped out. The way this works is that as the window slides along from left to right, the y value corresponding to the smallest x in the window should be the next one popped out. However, the position of this element within sorted_cdf_values can be anywhere, since there is no strict connection between the values of x and y. So the correspondence_indx array is used to keep track of the xordering of the yvalues stored in the sorted_cdf_values windows. In particular, the value of the first element in correspondence_indx stores the position of the mostrecently added element to sorted_cdf_values (i.e., the element with the largest x); the last element in correspondence_indx, element nwin1, stores the position of the element of sorted_cdf_values that will be the next one popped out (i.e., the element with the largest x); the middle element of correspondence_indx, element nwin/2, stores the position of the middle of the sorted_cdf_values window. Since the position within sorted_cdf_values is the rank, then sorted_cdf_values[correspondence_indx[nwin/2]] stores the value of ynew[i].