CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::modelling::numbercounts::Modelling_NumberCounts Class Reference

The class Modelling_NumberCounts. More...

#include <Modelling_NumberCounts.h>

Inheritance diagram for cbl::modelling::numbercounts::Modelling_NumberCounts:
Collaboration diagram for cbl::modelling::numbercounts::Modelling_NumberCounts:

Public Member Functions

void set_data_model_SF (const cosmology::Cosmology cosmology, const std::vector< double > radii, const double redshift, const std::string model, const double b_eff, double slope=0.854, double offset=0.420, const double deltav_NL=-0.795, const double del_c=1.69, const std::string method_Pk="EisensteinHu", const double k_Pk_ratio=-1., const bool store_output=true, const std::string output_root="test", const std::string interpType="Linear", const double k_max=100., const std::string input_file=par::defaultString, const bool is_parameter_file=true)
 Member functions used to set the model parameters. More...
 
virtual void set_data_model_snapshot (const cbl::cosmology::Cosmology cosmology={}, const double redshift=0., const std::string method_Pk="CAMB", const double k_min=1.e-4, const double k_max=100., const int step=500, const bool store_output=true, const int norm=-1, const double Delta=200., const bool isDelta_critical=true, const std::string model_MF="Tinker", const double Volume=par::defaultDouble, const double Mass_min=par::defaultDouble, const double Mass_max=par::defaultDouble, const int Mass_step=100, const double prec=1.e-4)
 set the data used to construct mass number counts of simulation snapshots More...
 
Constructors/destructors
 Modelling_NumberCounts ()=default
 default constuctor _NumberCounts
 
 Modelling_NumberCounts (const std::shared_ptr< cbl::measure::numbercounts::NumberCounts > nc)
 constuctor More...
 
 Modelling_NumberCounts (glob::HistogramType hist_type, double fact)
 constuctor More...
 
virtual ~Modelling_NumberCounts ()=default
 default destructor
 
Member functions used to get the protected members of the class
modelling::numbercounts::STR_NC_data_model data_model ()
 get the member m_data_model More...
 
modelling::numbercounts::STR_NCSF_data_model data_model_SF ()
 get the member m_data_model_SF More...
 
Member functions used to set the model parameters
void set_data_model (const cbl::cosmology::Cosmology cosmology={}, const double redshift=0., const std::string method_Pk="CAMB", const double k_min=1.e-4, const double k_max=100., const int step=500, const bool store_output=true, const int norm=-1, const double Delta=200., const bool isDelta_critical=true, const std::string model_MF="Tinker", const std::string selection_function_file=par::defaultString, const std::vector< int > selection_function_column={}, const double z_min=par::defaultDouble, const double z_max=par::defaultDouble, const int z_step=50, const double Mass_min=par::defaultDouble, const double Mass_max=par::defaultDouble, const int Mass_step=100, const double area_degrees=par::defaultDouble, const double prec=1.e-4)
 set the data used to construct generic models of number counts More...
 
void set_data_model (const cbl::cosmology::Cosmology cosmology, const std::vector< double > SF_weights, const double z_pivot, const double proxy_pivot, const double mass_pivot, const double log_base, const std::string method_Pk, const bool store_output=true, const int norm=-1, const double Delta=200., const bool isDelta_critical=true, const std::string model_MF="Tinker", const std::string model_bias="Tinker", const double z_min=par::defaultDouble, const double z_max=par::defaultDouble, const double area_degrees=par::defaultDouble, const double prec=1.e-4)
 set the data used to construct a model of number counts as a function of a mass proxy, here expressed as \(\lambda\), with the following functional form: More...
 
- Public Member Functions inherited from cbl::modelling::Modelling
void m_set_posterior (const int seed)
 set the interal variable m_posterior More...
 
 Modelling ()=default
 default constuctor
 
virtual ~Modelling ()=default
 default destructor
 
std::shared_ptr< data::Datadata ()
 return the dataset More...
 
std::shared_ptr< data::Datadata_fit ()
 return the dataset More...
 
std::shared_ptr< statistics::Likelihoodlikelihood ()
 return the likelihood parameters More...
 
std::shared_ptr< statistics::Posteriorposterior ()
 return the posterior parameters More...
 
std::shared_ptr< statistics::ModelParameterslikelihood_parameters ()
 return the likelihood parameters More...
 
std::shared_ptr< statistics::ModelParametersposterior_parameters ()
 return the posterior parameters More...
 
virtual void set_parameter_from_string (const std::string parameter, const double value)
 set the value of a parameter providing its name string More...
 
virtual double get_parameter_from_string (const std::string parameter) const
 get the value of a parameter providing its name string More...
 
std::shared_ptr< statistics::PriorDistributionget_prior (const int i)
 get the internal variable m_parameter_priors More...
 
std::shared_ptr< statistics::Modelget_response_function ()
 return the response function used to compute the super-sample covariance More...
 
void reset_fit_range ()
 reset the fit range More...
 
void set_fit_range (const double xmin, const double xmax)
 set the fit range More...
 
void set_fit_range (const double xmin, const double xmax, const double ymin, const double ymax)
 set the fit range More...
 
void set_data (const std::shared_ptr< data::Data > dataset)
 set the dataset More...
 
void set_likelihood (const statistics::LikelihoodType likelihood_type, const std::vector< size_t > x_index={0, 2}, const int w_index=-1, const double prec=1.e-10, const int Nres=-1)
 set the likelihood function More...
 
void set_likelihood (const cbl::statistics::Likelihood_function log_likelihood_function)
 set the likelihood function, given a user-defined log-likelihood function More...
 
void maximize_likelihood (const std::vector< double > start, const std::vector< std::vector< double >> parameter_limits, const unsigned int max_iter=10000, const double tol=1.e-6, const double epsilon=1.e-3)
 function that maximizes the posterior, finds the best-fit parameters and stores them in the model More...
 
void maximize_posterior (const std::vector< double > start, const unsigned int max_iter=10000, const double tol=1.e-6, const double epsilon=1.e-3, const int seed=666)
 function that maximizes the posterior, finds the best-fit parameters and stores them in the model More...
 
void sample_posterior (const int chain_size, const int nwalkers, const int seed=666, const double aa=2, const bool parallel=true)
 sample the posterior, initializing the chains by drawing from the prior distributions More...
 
void sample_posterior (const int chain_size, const int nwalkers, const double radius, const std::vector< double > start, const unsigned int max_iter=10000, const double tol=1.e-6, const double epsilon=1.e-3, const int seed=666, const double aa=2, const bool parallel=true)
 sample the posterior, initializing the chains in a ball around the posterior best-fit parameters values More...
 
void sample_posterior (const int chain_size, const int nwalkers, std::vector< double > &value, const double radius, const int seed=666, const double aa=2, const bool parallel=true)
 sample the posterior, initializing the chains by drawing from the prior distributions More...
 
void sample_posterior (const int chain_size, const std::vector< std::vector< double >> chain_value, const int seed=666, const double aa=2, const bool parallel=true)
 sample the posterior, initializing the chains with input values More...
 
void sample_posterior (const int chain_size, const int nwalkers, const std::string input_dir, const std::string input_file, const int seed=666, const double aa=2, const bool parallel=true)
 sample the posterior, initializing the chains reading the input values from an input file More...
 
void importance_sampling (const std::string input_dir, const std::string input_file, const int seed=666, const std::vector< size_t > column={}, const int header_lines_to_skip=1, const bool is_FITS_format=false, const bool apply_to_likelihood=false)
 perform importance sampling More...
 
void write_chain (const std::string output_dir, const std::string output_file, const int start=0, const int thin=1, const bool is_FITS_format=false, const int prec=5, const int ww=14)
 write the chains obtained after the MCMC sampling More...
 
void read_chain (const std::string input_dir, const std::string input_file, const int nwalkers, const std::vector< size_t > columns={}, const int skip_header=1, const bool fits=false)
 read the chains More...
 
void show_results (const int start=0, const int thin=1, const int nbins=50, const bool show_mode=false, const int ns=-1)
 show the results of the MCMC sampling on screen More...
 
void write_results (const std::string output_dir, const std::string root_file, const int start=0, const int thin=1, const int nbins=50, const bool fits=false, const bool compute_mode=false, const int ns=-1)
 write the results of the MCMC sampling to file More...
 
virtual void write_model (const std::string output_dir, const std::string output_file, const std::vector< double > xx, const std::vector< double > parameters)
 write the model at xx for given parameters More...
 
virtual void write_model (const std::string output_dir, const std::string output_file, const std::vector< double > xx, const std::vector< double > yy, const std::vector< double > parameters)
 write the model at xx, yy for given parameters More...
 
virtual void write_model_at_bestfit (const std::string output_dir, const std::string output_file, const std::vector< double > xx)
 write the model at xx with best-fit parameters obtained from posterior maximization More...
 
virtual void write_model_at_bestfit (const std::string output_dir, const std::string output_file, const std::vector< double > xx, const std::vector< double > yy)
 write the model at xx, yy with best-fit parameters obtained from likelihood maximization More...
 
virtual void write_model_from_chains (const std::string output_dir, const std::string output_file, const std::vector< double > xx, const int start=0, const int thin=1)
 write the model at xx computing 16th, 50th and 84th percentiles from the chains More...
 
virtual void write_model_from_chains (const std::string output_dir, const std::string output_file, const std::vector< double > xx, const std::vector< double > yy, const int start=0, const int thin=1)
 write the model at xx, yy computing 16th, 50th and 84th percentiles from the chains More...
 
double reduced_chi2 (const std::vector< double > parameter={})
 the reduced \(\chi^2\) More...
 

Protected Attributes

glob::HistogramType m_HistogramType
 the histogram type
 
double m_fact
 the normalization factor
 
modelling::numbercounts::STR_NC_data_model m_data_model
 the container of parameters for number counts model computation
 
modelling::numbercounts::STR_NCSF_data_model m_data_model_SF
 the container of parameters for size number counts model computation
 
- Protected Attributes inherited from cbl::modelling::Modelling
std::shared_ptr< data::Datam_data = NULL
 input data to be modelled
 
bool m_fit_range = false
 check if fit range has been set
 
std::shared_ptr< data::Datam_data_fit
 input data restricted to the range used for the fit
 
std::shared_ptr< statistics::Modelm_model = NULL
 input model
 
std::shared_ptr< statistics::Modelm_response_func = NULL
 response function for the computation of the super-sample covariance
 
std::shared_ptr< statistics::Likelihoodm_likelihood = NULL
 likelihood
 
std::vector< std::shared_ptr< statistics::PriorDistribution > > m_parameter_priors
 prior
 
std::shared_ptr< statistics::Posteriorm_posterior = NULL
 posterior
 

Additional Inherited Members

- Protected Member Functions inherited from cbl::modelling::Modelling
void m_set_prior (std::vector< statistics::PriorDistribution > prior_distribution)
 set the internal variable m_parameter_priors More...
 
void m_isSet_response ()
 check if the response function used to compute the super-sample covariance is set
 

Detailed Description

The class Modelling_NumberCounts.

Modelling_NumberCounts.h "Headers/Modelling_NumberCounts.h"

This file defines the interface of the base class Modelling_NumberCounts, used for modelling any kind of number counts measurements

Definition at line 70 of file Modelling_NumberCounts.h.

Constructor & Destructor Documentation

◆ Modelling_NumberCounts() [1/2]

cbl::modelling::numbercounts::Modelling_NumberCounts::Modelling_NumberCounts ( const std::shared_ptr< cbl::measure::numbercounts::NumberCounts nc)
inline

constuctor

Parameters
ncthe number counts to model _NumberCounts

Definition at line 104 of file Modelling_NumberCounts.h.

◆ Modelling_NumberCounts() [2/2]

cbl::modelling::numbercounts::Modelling_NumberCounts::Modelling_NumberCounts ( glob::HistogramType  hist_type,
double  fact 
)
inline

constuctor

Parameters
hist_typethe histogram type
factthe normalization factor _NumberCounts

Definition at line 113 of file Modelling_NumberCounts.h.

Member Function Documentation

◆ data_model()

modelling::numbercounts::STR_NC_data_model cbl::modelling::numbercounts::Modelling_NumberCounts::data_model ( )
inline

get the member m_data_model

Returns
the container of parameters for number counts model computation

Definition at line 134 of file Modelling_NumberCounts.h.

◆ data_model_SF()

modelling::numbercounts::STR_NCSF_data_model cbl::modelling::numbercounts::Modelling_NumberCounts::data_model_SF ( )
inline

get the member m_data_model_SF

Returns
the container of parameters for size number counts model computation

Definition at line 144 of file Modelling_NumberCounts.h.

◆ set_data_model() [1/2]

void cbl::modelling::numbercounts::Modelling_NumberCounts::set_data_model ( const cbl::cosmology::Cosmology  cosmology,
const std::vector< double >  SF_weights,
const double  z_pivot,
const double  proxy_pivot,
const double  mass_pivot,
const double  log_base,
const std::string  method_Pk,
const bool  store_output = true,
const int  norm = -1,
const double  Delta = 200.,
const bool  isDelta_critical = true,
const std::string  model_MF = "Tinker",
const std::string  model_bias = "Tinker",
const double  z_min = par::defaultDouble,
const double  z_max = par::defaultDouble,
const double  area_degrees = par::defaultDouble,
const double  prec = 1.e-4 
)

set the data used to construct a model of number counts as a function of a mass proxy, here expressed as \(\lambda\), with the following functional form:

\( \langle N(\Delta{\lambda_{\text{ob},i}},\Delta z_{\text{ob},j})\rangle = w(\Delta{\lambda_{\text{ob},i}},\Delta z_{\text{ob},j})\,\,\Omega \int_{0}^{\infty} {\rm d} z_{\rm tr}\,\, \frac{{\rm d} V}{{\rm d} z_{\rm tr}{\rm d}\Omega}\int_{0}^{\infty} {\rm d} M_{\rm tr} \,\,\frac{{\rm d} n(M_{\rm tr},z_{\rm tr})}{{\rm d} M_{\rm tr}}\,\, \int_{0}^{\infty}{\rm d}\lambda_{\rm tr}\,\, P(\lambda_{\rm tr}| M_{\rm tr},z_{\rm tr})\, \int_{\Delta z_{\text{ob},j}}{\rm d} z_{\rm ob} \,\,P(z_{\rm ob}|z_{\rm tr})\, \int_{\Delta\lambda_{\text{ob},i}}{\rm d} \lambda_{\rm ob} \,\,P(\lambda_{\rm ob}|\lambda_{\rm tr}), \)

where \( w(\Delta{\lambda_{\text{ob},i}},\Delta z_{\text{ob},j}) \) is the weight derived from the selection function (see e.g. Lesci et al. 2021), and \(\Omega\) is the survey effective area.

Furthermore, \(P(z_{\rm ob}|z_{\rm tr})\) and \(P(\lambda_{\rm ob}|\lambda_{\rm tr})\) are Gaussian distributions.

Parameters
cosmologythe cosmological model
SF_weightsthe counts weights derived from the selection function (see e.g. Lesci et al. 2021)
z_pivotthe redshift pivot in the scaling relation
proxy_pivotthe mass proxy pivot in the scaling relation
mass_pivotthe mass pivot; for example, if the scaling relation is written as \( \log [M/(10^{14}M_\odot /h)] = \alpha+\beta \log(\lambda/\lambda_{piv})+\gamma\log f(z) \), then mass_pivot = 1.e14
log_basethe base of the logarithm used in the mass-mass proxy scaling relation
method_Pkmethod used to compute the power spectrum (i.e. the Boltzmann solver); valid choices for method_Pk are: CAMB [http://camb.info/], CLASS [http://class-code.net/], MPTbreeze-v1 [http://arxiv.org/abs/1207.1465], EisensteinHu [http://background.uchicago.edu/~whu/transfer/transferpage.html]
store_outputif true the output files created by the Boltzmann solver are stored; if false the output files are removed
norm0 → don't normalize the power spectrum; 1 → normalize the power spectrum
Delta\(\Delta\), the overdensity
isDelta_critical\(\rightarrow\) \(\Delta\) is the overdensity defined with respect to the critical density
model_MFauthor(s) who proposed the mass function
model_biasauthor(s) who proposed the bias function, used for the transfer function necessary for the super-sample covariance
z_minminimum redshift
z_maxmaximum redshift
area_degreesthe area in degrees
precthe precision

Definition at line 106 of file Modelling_NumberCounts.cpp.

◆ set_data_model() [2/2]

void cbl::modelling::numbercounts::Modelling_NumberCounts::set_data_model ( const cbl::cosmology::Cosmology  cosmology = {},
const double  redshift = 0.,
const std::string  method_Pk = "CAMB",
const double  k_min = 1.e-4,
const double  k_max = 100.,
const int  step = 500,
const bool  store_output = true,
const int  norm = -1,
const double  Delta = 200.,
const bool  isDelta_critical = true,
const std::string  model_MF = "Tinker",
const std::string  selection_function_file = par::defaultString,
const std::vector< int >  selection_function_column = {},
const double  z_min = par::defaultDouble,
const double  z_max = par::defaultDouble,
const int  z_step = 50,
const double  Mass_min = par::defaultDouble,
const double  Mass_max = par::defaultDouble,
const int  Mass_step = 100,
const double  area_degrees = par::defaultDouble,
const double  prec = 1.e-4 
)

set the data used to construct generic models of number counts

Parameters
cosmologythe cosmological model used to compute ξDM
redshiftredshift
method_Pkmethod used to compute the power spectrum (i.e. the Boltzmann solver); valid choices for method_Pk are: CAMB [http://camb.info/], CLASS [http://class-code.net/], MPTbreeze-v1 [http://arxiv.org/abs/1207.1465], EisensteinHu [http://background.uchicago.edu/~whu/transfer/transferpage.html]
k_minminimum wave vector module up to which the binned dark matter power spectrum is computed
k_maxmaximum wave vector module up to which the binned dark matter power spectrum is computed
stepnumber of steps used to compute the binned power spectrum
store_outputif true the output files created by the Boltzmann solver are stored; if false the output files are removed
norm0 → don't normalize the power spectrum; 1 → normalize the power spectrum
Delta\(\Delta\), the overdensity
isDelta_critical\(\rightarrow\) \(\Delta\) is the overdensity defined with respect to the critical density
model_MFauthor(s) who proposed the mass function
selection_function_fileinput file with the selection function
selection_function_columnvector containing the columns with {mass, redshift, selection function}
z_minminimum redshift
z_maxmaximum redshift
z_stepthe number of bins for redshift vector
Mass_minminimum halo mass
Mass_maxmaximum halo mass
Mass_stepthe number of bins for mass vector
area_degreesthe area in degrees
precthe precision

Definition at line 47 of file Modelling_NumberCounts.cpp.

◆ set_data_model_SF()

void cbl::modelling::numbercounts::Modelling_NumberCounts::set_data_model_SF ( const cosmology::Cosmology  cosmology,
const std::vector< double >  radii,
const double  redshift,
const std::string  model,
const double  b_eff,
double  slope = 0.854,
double  offset = 0.420,
const double  deltav_NL = -0.795,
const double  del_c = 1.69,
const std::string  method_Pk = "EisensteinHu",
const double  k_Pk_ratio = -1.,
const bool  store_output = true,
const std::string  output_root = "test",
const std::string  interpType = "Linear",
const double  k_max = 100.,
const std::string  input_file = par::defaultString,
const bool  is_parameter_file = true 
)

Member functions used to set the model parameters.

Parameters
cosmologythe cosmological model used to compute the void size function
radiithe void radii
redshiftthe redshift
modelsize function model name; valid choices for model name are SvdW (Sheth and van de Weygaert, 2004), linear and Vdn (Jennings et al., 2013)
b_effthe effective bias of the sample
slopefirst coefficent to convert the effective bias (default value set to \(0.854\))
offsetsecond coefficent to convert the effective bias (default value set to \(0.420\))
deltav_NLthe non linear density contrast: \(\rho_v/\rho_m\) (default value set to \(-0.795\))
del_ccritical value of the linear density field (default value set to \(1.06\))
method_Pkmethod used to compute the power spectrum (i.e. the Boltzmann solver); valid choices for method_Pk are: CAMB [http://camb.info/], CLASS [http://class-code.net/], MPTbreeze-v1 [http://arxiv.org/abs/1207.1465], EisensteinHu [http://background.uchicago.edu/~whu/transfer/transferpage.html]
k_Pk_ratiowave vector module required to compute the growth factor (cbl::cosmology::Cosmology::DD_norm()) with the method "Pk_ratio". This parameter represents wavenumber at which the ratio between the the power spectra at different redshift is computed. It is recommended to use this method when dealing with cosmologies alternative to the LCDM. To avoid to compute the growth factor with this method, set k_Pk_ratio=-1.
store_outputif true the output files created by the Boltzmann solver are stored; if false the output files are removed
output_rootoutput_root of the parameter file used to compute the power spectrum and σ(mass); it can be any name
interpTypemethod to interpolate the power spectrum
k_maxmaximum wave vector module up to which the power spectrum is computed
input_fileeither the parameter file or the power spectrum file; if a parameter file is provided, i.e. input_file!=NULL and is_parameter_file=true, it will be used to compute the power spectrum; if a power spectrum file is provided, i.e. input_file!=NULL and is_parameter_file=false, then the provided power spectrum will be used directly; in both cases σ2(M) is computed by integrating the computed/provided power spectrum ignoring the cosmological parameters of the object
is_parameter_filetrue \(\rightarrow\) the input_file is a parameter file, used to compute the power spectrum with the method specified by method_Pk; false \(\rightarrow\) the input_file is a file containing the power spectrum
Examples
modelling_VoidAbundances.cpp.

Definition at line 163 of file Modelling_NumberCounts.cpp.

◆ set_data_model_snapshot()

virtual void cbl::modelling::numbercounts::Modelling_NumberCounts::set_data_model_snapshot ( const cbl::cosmology::Cosmology  cosmology = {},
const double  redshift = 0.,
const std::string  method_Pk = "CAMB",
const double  k_min = 1.e-4,
const double  k_max = 100.,
const int  step = 500,
const bool  store_output = true,
const int  norm = -1,
const double  Delta = 200.,
const bool  isDelta_critical = true,
const std::string  model_MF = "Tinker",
const double  Volume = par::defaultDouble,
const double  Mass_min = par::defaultDouble,
const double  Mass_max = par::defaultDouble,
const int  Mass_step = 100,
const double  prec = 1.e-4 
)
inlinevirtual

set the data used to construct mass number counts of simulation snapshots

Parameters
cosmologythe cosmological model used to compute ξDM
redshiftredshift
method_Pkmethod used to compute the power spectrum (i.e. the Boltzmann solver); valid choices for method_Pk are: CAMB [http://camb.info/], CLASS [http://class-code.net/], MPTbreeze-v1 [http://arxiv.org/abs/1207.1465], EisensteinHu [http://background.uchicago.edu/~whu/transfer/transferpage.html]
k_minminimum wave vector module up to which the binned dark matter power spectrum is computed
k_maxmaximum wave vector module up to which the binned dark matter power spectrum is computed
stepnumber of steps used to compute the binned power spectrum
store_outputif true the output files created by the Boltzmann solver are stored; if false the output files are removed
norm0 → don't normalize the power spectrum; 1 → normalize the power spectrum
Delta\(\Delta\), the overdensity
isDelta_critical\(\rightarrow\) \(\Delta\) is the overdensity defined with respect to the critical density
model_MFauthor(s) who proposed the mass function
Volumethe snapshot volume
Mass_minminimum halo mass
Mass_maxmaximum halo mass
Mass_stepthe number of bins for mass vector
precthe precision

Definition at line 430 of file Modelling_NumberCounts.h.


The documentation for this class was generated from the following files: