![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class Modelling_NumberCounts1D_MassProxy. More...
#include <Modelling_NumberCounts1D_MassProxy.h>
Public Member Functions | |
Constructors/destructors | |
Modelling_NumberCounts1D_MassProxy ()=default | |
default constuctor _NumberCounts1D_MassProxy | |
Modelling_NumberCounts1D_MassProxy (const std::shared_ptr< cbl::measure::numbercounts::NumberCounts > nc) | |
constuctor More... | |
Modelling_NumberCounts1D_MassProxy (const std::shared_ptr< cbl::data::Data > dataset, glob::HistogramType hist_type, double fact) | |
constuctor More... | |
virtual | ~Modelling_NumberCounts1D_MassProxy ()=default |
default destructor | |
Member functions used to set the model parameters | |
void | set_model_NumberCounts_cosmology (const std::string scalrel_z_evo, const std::string z_error_type, const std::string proxy_error_type, const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_param, const std::vector< statistics::PriorDistribution > cosmo_param_prior, const statistics::PriorDistribution alpha_prior, const statistics::PriorDistribution beta_prior, const statistics::PriorDistribution gamma_prior, const statistics::PriorDistribution scatter0_prior, const statistics::PriorDistribution scatterM_prior, const statistics::PriorDistribution scatterM_exponent_prior, const statistics::PriorDistribution scatterz_prior, const statistics::PriorDistribution scatterz_exponent_prior, const statistics::PriorDistribution z_bias_prior, const statistics::PriorDistribution proxy_bias_prior, const statistics::PriorDistribution z_error_prior, const statistics::PriorDistribution proxy_error_prior, const std::vector< statistics::PriorDistribution > Plambda_prior) |
Set the cosmological parameters used to model the number counts as a function of a mass proxy, here written as \(\lambda\), with the model expressed as follows: More... | |
![]() | |
Modelling_NumberCounts1D ()=default | |
default constuctor | |
Modelling_NumberCounts1D (const std::shared_ptr< cbl::measure::numbercounts::NumberCounts > nc) | |
constuctor More... | |
Modelling_NumberCounts1D (const std::shared_ptr< cbl::data::Data > dataset, glob::HistogramType hist_type, double fact) | |
constuctor More... | |
virtual | ~Modelling_NumberCounts1D ()=default |
default destructor | |
![]() | |
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... | |
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 | |
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... | |
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... | |
![]() | |
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::Data > | data () |
return the dataset More... | |
std::shared_ptr< data::Data > | data_fit () |
return the dataset More... | |
std::shared_ptr< statistics::Likelihood > | likelihood () |
return the likelihood parameters More... | |
std::shared_ptr< statistics::Posterior > | posterior () |
return the posterior parameters More... | |
std::shared_ptr< statistics::ModelParameters > | likelihood_parameters () |
return the likelihood parameters More... | |
std::shared_ptr< statistics::ModelParameters > | posterior_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::PriorDistribution > | get_prior (const int i) |
get the internal variable m_parameter_priors More... | |
std::shared_ptr< statistics::Model > | get_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... | |
Additional Inherited Members | |
![]() | |
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 | |
![]() | |
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 | |
![]() | |
std::shared_ptr< data::Data > | m_data = NULL |
input data to be modelled | |
bool | m_fit_range = false |
check if fit range has been set | |
std::shared_ptr< data::Data > | m_data_fit |
input data restricted to the range used for the fit | |
std::shared_ptr< statistics::Model > | m_model = NULL |
input model | |
std::shared_ptr< statistics::Model > | m_response_func = NULL |
response function for the computation of the super-sample covariance | |
std::shared_ptr< statistics::Likelihood > | m_likelihood = NULL |
likelihood | |
std::vector< std::shared_ptr< statistics::PriorDistribution > > | m_parameter_priors |
prior | |
std::shared_ptr< statistics::Posterior > | m_posterior = NULL |
posterior | |
The class Modelling_NumberCounts1D_MassProxy.
Modelling_NumberCounts1D_MassProxy.h "Headers/Modelling_NumberCounts1D_MassProxy.h"
This file defines the interface of the base class Modelling_NumberCounts1D_MassProxy, used for modelling number counts measurements as a function of a mass proxy
Definition at line 69 of file Modelling_NumberCounts1D_MassProxy.h.
|
inline |
constuctor
nc | the number counts to model |
Definition at line 89 of file Modelling_NumberCounts1D_MassProxy.h.
|
inline |
constuctor
dataset | the number counts dataset |
hist_type | the histogram type |
fact | the normalization factor |
Definition at line 98 of file Modelling_NumberCounts1D_MassProxy.h.
void cbl::modelling::numbercounts::Modelling_NumberCounts1D_MassProxy::set_model_NumberCounts_cosmology | ( | const std::string | scalrel_z_evo, |
const std::string | z_error_type, | ||
const std::string | proxy_error_type, | ||
const std::vector< cbl::cosmology::CosmologicalParameter > | cosmo_param, | ||
const std::vector< statistics::PriorDistribution > | cosmo_param_prior, | ||
const statistics::PriorDistribution | alpha_prior, | ||
const statistics::PriorDistribution | beta_prior, | ||
const statistics::PriorDistribution | gamma_prior, | ||
const statistics::PriorDistribution | scatter0_prior, | ||
const statistics::PriorDistribution | scatterM_prior, | ||
const statistics::PriorDistribution | scatterM_exponent_prior, | ||
const statistics::PriorDistribution | scatterz_prior, | ||
const statistics::PriorDistribution | scatterz_exponent_prior, | ||
const statistics::PriorDistribution | z_bias_prior, | ||
const statistics::PriorDistribution | proxy_bias_prior, | ||
const statistics::PriorDistribution | z_error_prior, | ||
const statistics::PriorDistribution | proxy_error_prior, | ||
const std::vector< statistics::PriorDistribution > | Plambda_prior | ||
) |
Set the cosmological parameters used to model the number counts as a function of a mass proxy, here written as \(\lambda\), with the model expressed as follows:
\( \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.
The distirbution \(P(\lambda_{\rm tr}| M_{\rm tr},z_{\rm tr})\) is expressed as:
\(P(\lambda_{\rm tr}|M_{\rm tr},z_{\rm tr})= P(M_{\rm tr}|\lambda_{\rm tr},z_{\rm tr})\, P(\lambda_{\rm tr}|z_{\rm tr})\,/\,P( M_{\rm tr}|z_{\rm tr}),\)
where \(P(M_{\rm tr}|\lambda_{\rm tr},z_{\rm tr})\) is a log-normal whose mean is given by the mass-mass proxy relation, i.e.
\(\log M = \alpha + \beta \log (\lambda/\lambda_{\rm piv}) + \gamma \log (f(z)),\)
and whose standard deviation is given by the intrinsic scatter, \( \sigma_{\rm intr} \), expressed as:
\( \sigma_{\rm intr} = \sigma_0 + \sigma_{\lambda} \log (\lambda/\lambda_{\rm piv})^{e_{\lambda}} + \sigma_z \log (f(z))^{e_z}.\)
The distribution \( P(\lambda_{\rm tr}|z_{\rm tr}) \) is derived from mock catalogues, and it has the functional form of a power-law with an exponential cut-off, i.e.: \( P(\lambda_{\rm tr}|z_{\rm tr}) = a \, \lambda_{\rm tr}^{-b} \, e^{-c\lambda_{\rm tr}} \).
Furthermore, \(P( M_{\rm tr}|z_{\rm tr}) = \int_{0}^{\infty} {\rm d} \lambda_{\rm tr}\, P(M_{\rm tr}|\lambda_{\rm tr},z_{\rm tr})\,P(\lambda_{\rm tr}|z_{\rm tr}).\)
Finally, \(P(z_{\rm ob}|z_{\rm tr})\) and \(P(\lambda_{\rm ob}|\lambda_{\rm tr})\) are Gaussian distributions.
scalrel_z_evo | functional form of the redshift evolution function in the scaling relation: "E_z" \(\rightarrow\) \( f(z)=E(z)/E(z_{piv}) \), "direct" \(\rightarrow\) \( f(z)=(1+z)/(1+z_{piv}) \) |
z_error_type | if "absolute", set the absolute error on redshift in the model; if "relative", set the relative error |
proxy_error_type | if "absolute", set the absolute error on the mass proxy in the model; if "relative", set the relative error |
cosmo_param | vector of enums containing cosmological parameters |
cosmo_param_prior | vector containing the priors for the cosmological parameters |
alpha_prior | prior on the normalization of the mass-mass proxy scaling relation, \(\alpha\) |
beta_prior | prior on the slope of the mass-mass proxy scaling relation, \(\beta\) |
gamma_prior | prior on the redshift evolution factor of the mass-mass proxy scaling relation, \(\gamma\) |
scatter0_prior | prior on the constant term of the intrinsic scatter, \( \sigma_0 \) |
scatterM_prior | prior on the factor in the proxy-dependent term of the intrinsic scatter, \( \sigma_{\lambda} \) |
scatterM_exponent_prior | prior on the exponent in the proxy-dependent term of the intrinsic scatter, \( e_{\lambda} \) |
scatterz_prior | prior on the factor in the redshift-dependent term of the intrinsic scatter, \( \sigma_z \) |
scatterz_exponent_prior | prior on the exponent in the redshift-dependent term of the intrinsic scatter, \( e_z \) |
z_bias_prior | prior on the redshif bias, governing the position of the mean of the Gaussian \( P(z_{\rm ob}|z_{\rm tr}) \). For example, let's say that the redshift bias in the data is \(\Delta z=0.02\): the data redshifts would be corrected as \(z_{\rm corr} = z - 0.02 (1+z)\), where \(z\) is the not corrected redshift. If you correct the data in this way, set this prior as constant and equal to zero. Otherwise you can choose to not correct the data and set a non-zero prior on the redshift bias: in this case, the mean of \( P(z_{\rm ob}|z_{\rm tr}) \) will be given by \(z_{\rm corr} = z + \Delta z (1+z)\). |
proxy_bias_prior | prior on the mass proxy bias, analogous to z_bias_prior |
z_error_prior | prior on the redshift error, governing the distribution \( P(z_{\rm ob}|z_{\rm tr}) \). Depending on the input parameter z_error_type, this prior is related to the absolute error or to the relative error |
proxy_error_prior | prior on the mass proxy error, governing the distribution \( P(\lambda_{\rm ob}|\lambda_{\rm tr}) \). Depending on the input parameter proxy_error_type, this prior is related to the absolute error or to the relative error |
Plambda_prior | priors on the three parameters, respectively \( a \), \( b \), \( c \), defining the distribution \( P(\lambda_{\rm tr}|z_{\rm tr}) \) |
Definition at line 50 of file Modelling_NumberCounts1D_MassProxy.cpp.