mock.NbarFitting(ps, hod, nbar_obs, z_min, z_max)
nbar_obs
is an array of z, nbar
or z, nbar, dnbar
with error%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import mockgallib as mock
mock.set_loglevel(2)
mock.cosmology_set(0.31) # set omega_m
ps = mock.PowerSpectrum('../data/planck1_matterpower.dat') # power spectrum is required to compute mass function
hod = mock.Hod()
# The target of fitting
nbar_obs= np.loadtxt('../data/nbar_vipers.txt', delimiter=' ')
fitting= mock.NbarFitting(ps, hod, nbar_obs, 0.6, 1.2)
fitting.fit()
print("number of iteration: %d" % fitting.iter)
print("chi2 = %.3e" % fitting.chi2)
print(hod)
fitting.z
: redshifts of the datafitting.nbar_obs
: input nbarfitting.nbar_hod
: best-fitting HOD number densityplt.plot(nbar_obs[:,0], nbar_obs[:,1], 'b-', label='target nbar');
plt.plot(fitting.z, fitting.nbar_hod, 'r+', label='hod nbar');
plt.xlim([0.4, 1.2])
plt.xlabel('$z$')
plt.ylabel('$\\bar{n}$')
plt.legend()
plt.show();