halotools.mock_observables.hod_from_mock(haloprop_galaxies, haloprop_halos, haloprop_bins=None)[source] [edit on github]

Calculate the HOD of a mock galaxy sample.


haloprop_galaxies : ndarray

Array of shape (num_galaxies, ) used to bin the galaxies according to the property of their host halo, e.g., host halo mass.

If this quantity is not readily available in the mock galaxy catalog, the get_haloprop_of_galaxies function can be used to calculate it.

haloprop_halos : ndarray

Array of shape (num_halos, ) used to bin the halos in the same manner as the galaxies so that the counts in each bin can be properly normalized.

haloprop_bins : ndarray, optional

Array defining the bin edges. If this array is not passed, then you will probably obtain better results if you pass in logarithmic quantities for the haloprop_galaxies and haloprop_halos arrays.


mean_occupation : ndarray

Array of shape (num_bins-1, ) storing the mean occupation of the input galaxy sample as a function of the input halo property.

bin_edges : ndarray

Array of shape (num_bins, ) storing the bin edges used in the calculation.


In the following calculation, we’ll populate a mock catalog and then manually compute the central galaxy HOD from the galaxy_table.

>>> from halotools.empirical_models import PrebuiltHodModelFactory
>>> from halotools.sim_manager import FakeSim
>>> model = PrebuiltHodModelFactory('leauthaud11', threshold=10.75)
>>> halocat = FakeSim()
>>> model.populate_mock(halocat)

Now compute \(\langle N_{\rm cen} \rangle(M_{\rm vir})\):

>>> cenmask = model.mock.galaxy_table['gal_type'] == 'centrals'
>>> central_host_mass = model.mock.galaxy_table['halo_mvir'][cenmask]
>>> halo_mass = model.mock.halo_table['halo_mvir']
>>> haloprop_bins = np.logspace(11, 15, 15)
>>> mean_ncen, bin_edges = hod_from_mock(central_host_mass, halo_mass, haloprop_bins)