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

The class Modelling_MassObservableRelation. More...

#include <Modelling_MassObservableRelation.h>

Inheritance diagram for cbl::modelling::massobsrel::Modelling_MassObservableRelation:
Collaboration diagram for cbl::modelling::massobsrel::Modelling_MassObservableRelation:

Public Member Functions

Constructors/destructors
 Modelling_MassObservableRelation ()=default
 default constuctor _MassObservableRelation
 
 Modelling_MassObservableRelation (const std::shared_ptr< cbl::data::Data > dataset)
 constuctor for the modelling of the cluster mass - mass proxy relation. Cosmological units are forced More...
 
virtual ~Modelling_MassObservableRelation ()=default
 default destructor
 
Member functions used to set the protected members of the class
STR_MOrelation_data_model data_model ()
 get the member m_data_model More...
 
Member functions used to set the model parameters
void set_mass_pivot (const double mass_pivot)
 Set the mass pivot. More...
 
void set_data_model (const cbl::cosmology::Cosmology cosmology, const std::vector< double > redshift, const double redshift_pivot, const double proxy_pivot, const double log_base)
 Set the data used to construct the scaling relation, written as: More...
 
void set_data_model (const cbl::cosmology::Cosmology cosmology, const std::vector< double > redshift, const double redshift_pivot, const double proxy_pivot, const double log_base, const std::vector< double > Nclusters)
 Set the data used to construct the scaling relation, written as: More...
 
void set_model_MassObservableRelation_cosmology (const std::string z_evo, const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_param, const std::vector< statistics::PriorDistribution > cosmo_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)
 Set the scaling relation and cosmological parameters, where the scaling relation is written as. 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

STR_MOrelation_data_model m_data_model
 the container of parameters for the model computation
 
bool m_isSet_Nclusters = false
 check if the number of clusters in the bin is set
 
- 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_MassObservableRelation.

Modelling_MassObservableRelation.h "Headers/Modelling_MassObservableRelation.h"

This file defines the interface of the base class Modelling_MassObservableRelation, used for modelling the cluster mass - mass proxy scaling relation. Cosmological units are forced.

Definition at line 179 of file Modelling_MassObservableRelation.h.

Constructor & Destructor Documentation

◆ Modelling_MassObservableRelation()

cbl::modelling::massobsrel::Modelling_MassObservableRelation::Modelling_MassObservableRelation ( const std::shared_ptr< cbl::data::Data dataset)
inline

constuctor for the modelling of the cluster mass - mass proxy relation. Cosmological units are forced

Parameters
datasetthe dataset containing x, data and errors

Definition at line 207 of file Modelling_MassObservableRelation.h.

Member Function Documentation

◆ data_model()

STR_MOrelation_data_model cbl::modelling::massobsrel::Modelling_MassObservableRelation::data_model ( )
inline

get the member m_data_model

Returns
the container of parameters for cluster mass - mass proxy scaling relation model computation

Definition at line 228 of file Modelling_MassObservableRelation.h.

◆ set_data_model() [1/2]

void cbl::modelling::massobsrel::Modelling_MassObservableRelation::set_data_model ( const cbl::cosmology::Cosmology  cosmology,
const std::vector< double >  redshift,
const double  redshift_pivot,
const double  proxy_pivot,
const double  log_base 
)

Set the data used to construct the scaling relation, written as:

\(\log M = \alpha + \beta \log (\lambda/\lambda_{\rm piv}) + \gamma \log (f(z)),\)

where \(\lambda\) is the mass proxy.

Parameters
cosmologythe cosmological model
redshiftredshift array
redshift_pivotredshift pivot value
proxy_pivotproxy or mass pivot value
log_basebase of the mass and proxy logarithms

Definition at line 47 of file Modelling_MassObservableRelation.cpp.

◆ set_data_model() [2/2]

void cbl::modelling::massobsrel::Modelling_MassObservableRelation::set_data_model ( const cbl::cosmology::Cosmology  cosmology,
const std::vector< double >  redshift,
const double  redshift_pivot,
const double  proxy_pivot,
const double  log_base,
const std::vector< double >  Nclusters 
)

Set the data used to construct the scaling relation, written as:

\(\log M = \int_0^\infty {\rm d}\log M_{\rm tr}\,\, \log M_{\rm tr} \, P(\log M_{\rm tr}|\lambda_{\rm eff},z_{\rm eff}) \,,\)

where \(\lambda\) is the mass proxy. The distirbution \(P(M| \lambda,z)\) is a log-normal whose mean is given by the mass-mass proxy relation, i.e.

\(\log (M/M_{\rm piv}) = \alpha + \beta \log (\lambda/\lambda_{\rm piv}) + \gamma \log (f(z)),\)

and whose standard deviation is given by the intrinsic scatter computed in the \(j\)-th bin of proxy and redshift, \( \sigma_{{\rm intr},j} \), expressed as

\( \sigma_{{\rm intr},j} = \frac{1}{N_{{\rm cl},j}}\left[\sigma_0 + \sigma_{\lambda} \log (\lambda/\lambda_{\rm piv})^{e_{\lambda}} + \sigma_z \log (f(z))^{e_z}\right]\,, \)

where \(N_{{\rm cl},j}\) is the number of clusters used for the stacking in the bin.

Parameters
cosmologythe cosmological model
redshiftredshift array
redshift_pivotredshift pivot value
proxy_pivotproxy or mass pivot value
log_basebase of the mass and proxy logarithms
Nclustersnumber of clusters in the bin

Definition at line 63 of file Modelling_MassObservableRelation.cpp.

◆ set_mass_pivot()

void cbl::modelling::massobsrel::Modelling_MassObservableRelation::set_mass_pivot ( const double  mass_pivot)
inline

Set the mass pivot.

Parameters
mass_pivotthe mass pivot

Definition at line 244 of file Modelling_MassObservableRelation.h.

◆ set_model_MassObservableRelation_cosmology()

void cbl::modelling::massobsrel::Modelling_MassObservableRelation::set_model_MassObservableRelation_cosmology ( const std::string  z_evo,
const std::vector< cbl::cosmology::CosmologicalParameter cosmo_param,
const std::vector< statistics::PriorDistribution cosmo_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 
)

Set the scaling relation and cosmological parameters, where the scaling relation is written as.

\(\log M = \alpha + \beta \log (\lambda_{\rm eff}/\lambda_{\rm piv}) + \gamma \log (f(z_{\rm eff})),\,\,\,\,(1)\)

or as

\(\log M = \log \left[ \int_0^\infty {\rm d}M_{\rm tr}\,\, M_{\rm tr} \, P(M_{\rm tr}|\lambda_{\rm eff},z_{\rm eff}) \right] \,,\,\,\,\,(2)\)

depending on the cbl::modelling::massobsrel::Modelling_MassObservableRelation::set_data_model() used. In Eq. (2), the distirbution \(P(M| \lambda,z)\) is a log-normal whose mean is given by the mass-mass proxy relation, i.e.

\(\log (M/M_{\rm piv}) = \alpha + \beta \log (\lambda/\lambda_{\rm piv}) + \gamma \log (f(z)),\)

and whose standard deviation is given by the intrinsic scatter, computed in the \(j\)-th bin of proxy and redshift, \( \sigma_{{\rm intr},j} \), expressed as

\( \sigma_{{\rm intr},j} = \frac{1}{N_{{\rm cl},j}}\left[\sigma_0 + \sigma_{\lambda} \log (\lambda/\lambda_{\rm piv})^{e_{\lambda}} + \sigma_z \log (f(z))^{e_z}\right]\,, \)

where \(N_{{\rm cl},j}\) is the number of clusters used for the stacking in the bin.

WARNING: in case of Eq. (1), the only way to have a dependency on the intrinsic scatter parameters is to define a user-defined likelihood, whose covariance depends on the intrinsic scatter. In particular the intrinsic scatter, \(\sigma_{\rm intr}\), is expressed as

\( \sigma_{\rm intr} = \sigma_0 + \sigma_{\lambda} \log (\lambda/\lambda_{\rm piv})^{e_{\lambda}} + \sigma_z \log (f(z))^{e_z}.\)

Parameters
z_evofunctional 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}) \)
cosmo_paramvector of enums containing cosmological parameters
cosmo_priorvector containing the priors for the cosmological parameters
alpha_priorprior on the scaling relation normalization
beta_priorprior on the scaling relation slope
gamma_priorprior on the redshift evolution factor of the scaling relation
scatter0_priorprior on the constant term of the intrinsic scatter, \( \sigma_0 \)
scatterM_priorprior on the factor in the proxy-dependent term of the intrinsic scatter, \( \sigma_{\lambda} \)
scatterM_exponent_priorprior on the exponent in the proxy-dependent term of the intrinsic scatter, \( e_{\lambda} \)
scatterz_priorprior on the factor in the redshift-dependent term of the intrinsic scatter, \( \sigma_z \)
scatterz_exponent_priorprior on the exponent in the redshift-dependent term of the intrinsic scatter, \( e_z \)

Definition at line 85 of file Modelling_MassObservableRelation.cpp.


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