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

The class Modelling_PowerSpectrum_angular. More...

#include <Modelling_PowerSpectrum_Angular.h>

Inheritance diagram for cbl::modelling::angularpk::Modelling_PowerSpectrum_angular:
Collaboration diagram for cbl::modelling::angularpk::Modelling_PowerSpectrum_angular:

Public Member Functions

Constructors/destructors
 Modelling_PowerSpectrum_angular ()=default
 default constuctor
 
 Modelling_PowerSpectrum_angular (const std::shared_ptr< cbl::measure::angularpk::PowerSpectrum_angular > Pow)
 constructor More...
 
 Modelling_PowerSpectrum_angular (const std::shared_ptr< data::Data > dataset)
 constructor More...
 
virtual ~Modelling_PowerSpectrum_angular ()=default
 default destructor
 
Member functions used to set the model parameters
void set_model_limber (const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_param, const std::vector< statistics::PriorDistribution > cosmo_prior, const statistics::PriorDistribution bias_prior)
 set the model to fit the angular power spectrum More...
 
void set_model_limber (const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_param, const std::vector< statistics::PriorDistribution > cosmo_prior, const statistics::PriorDistribution bias_prior, const statistics::PriorDistribution offset_slope_prior)
 set the model to fit the angular power spectrum More...
 
void set_model_limber_cross (const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_param, const std::vector< statistics::PriorDistribution > cosmo_prior, const statistics::PriorDistribution bias_prior_bin1, const statistics::PriorDistribution bias_prior_bin2)
 set the model to fit the cross correlation angular power spectrum More...
 
std::shared_ptr< modelling::angularpk::STR_data_model > data_model ()
 get the member m_data_model More...
 
void set_data_model (const cbl::cosmology::Cosmology cosmology, const double z_min=0., const double z_max=10., const std::string method_Pk="CAMB", const bool NL=false, const int norm=-1, const double k_min=0.001, const double k_max=5., const std::vector< double > dN_par={}, const double fsky=1., std::vector< double > ll={}, std::vector< std::vector< double >> mixing_matrix={}, const bool interpolate_power_spectrum=false)
 Set the data used to construct models of the angular power spectrum. More...
 
void set_data_model_cross (const cbl::cosmology::Cosmology cosmology, const double z_min=0., const double z_max=10., const std::string method_Pk="CAMB", const bool NL=false, const int norm=-1, const double k_min=0.001, const double k_max=5., const std::vector< double > dN_par={}, const double fsky=1., std::vector< double > ll={}, std::vector< std::vector< double >> mixing_matrix={}, const bool interpolate_power_spectrum=false, const double z_min_bin2=-1., const double z_max_bin2=-1., const std::vector< double > dN_par_bin2={})
 Set the data used to construct models of the angular power spectrum. 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

std::shared_ptr< modelling::angularpk::STR_data_model > m_data_model
 the container of parameters for angular power spectrum 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_PowerSpectrum_angular.

Modelling_PowerSpectrum_Angular.h "Headers/Modelling_PowerSpectrum_Angular.h"

This file defines the interface of the base class Modelling_PowerSpectrum_angular, used for modelling the angular power spectrum

Examples
model_power_spectrum_angular.cpp.

Definition at line 61 of file Modelling_PowerSpectrum_Angular.h.

Constructor & Destructor Documentation

◆ Modelling_PowerSpectrum_angular() [1/2]

cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::Modelling_PowerSpectrum_angular ( const std::shared_ptr< cbl::measure::angularpk::PowerSpectrum_angular Pow)
inline

constructor

Parameters
Powthe angular power spectrum to model

Definition at line 84 of file Modelling_PowerSpectrum_Angular.h.

◆ Modelling_PowerSpectrum_angular() [2/2]

cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::Modelling_PowerSpectrum_angular ( const std::shared_ptr< data::Data dataset)
inline

constructor

Parameters
datasetthe dataset containing the angular power spectrum to model

Definition at line 93 of file Modelling_PowerSpectrum_Angular.h.

Member Function Documentation

◆ data_model()

std::shared_ptr<modelling::angularpk::STR_data_model> cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::data_model ( )
inline

get the member m_data_model

Returns
the container of parameters for two-point correlation function model computation

Definition at line 198 of file Modelling_PowerSpectrum_Angular.h.

◆ set_data_model()

void cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::set_data_model ( const cbl::cosmology::Cosmology  cosmology,
const double  z_min = 0.,
const double  z_max = 10.,
const std::string  method_Pk = "CAMB",
const bool  NL = false,
const int  norm = -1,
const double  k_min = 0.001,
const double  k_max = 5.,
const std::vector< double >  dN_par = {},
const double  fsky = 1.,
std::vector< double >  ll = {},
std::vector< std::vector< double >>  mixing_matrix = {},
const bool  interpolate_power_spectrum = false 
)

Set the data used to construct models of the angular power spectrum.

Parameters
cosmologythe cosmological model used to measure angular power spectrum
z_minthe minimum redshift of the first redshift slice or of the full integral in one bin case
z_maxthe maximum redshift of the first redshift slice or of the full integral in one bin case
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]
NL0 \(\rightarrow\) linear power spectrum; 1 \(\rightarrow\) non-linear power spectrum
norm0 \(\rightarrow\) don't normalise the power spectrum; 1 \(\rightarrow\) normalise the power spectrum; -1 \(\rightarrow\) normalise only if sigma8 is set
k_minminimum wave vector module up to which the power spectrum is computed in order to estimate the power spectrum normalisation; this parameter is used only if either norm=1, or norm=-1 and sigma8 is set
k_maxmaximum wave vector module up to which the power spectrum is computed to estimate the power spectrum normalisation; this parameter is used only if norm=1
dN_paroffset, slope and parameters of the dN/dz normalized distribution for the first redshift slice
fskythe fraction of the sky covered by the survey
llthe vector of the multipoles of the mixing matrix
mixing_matrixthe mixing matrix
interpolate_power_spectrumdefault false, true if you want to interpolate the 3D power spectrum on a grid (faster)
Examples
model_power_spectrum_angular.cpp.

Definition at line 48 of file Modelling_PowerSpectrum_Angular.cpp.

◆ set_data_model_cross()

void cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::set_data_model_cross ( const cbl::cosmology::Cosmology  cosmology,
const double  z_min = 0.,
const double  z_max = 10.,
const std::string  method_Pk = "CAMB",
const bool  NL = false,
const int  norm = -1,
const double  k_min = 0.001,
const double  k_max = 5.,
const std::vector< double >  dN_par = {},
const double  fsky = 1.,
std::vector< double >  ll = {},
std::vector< std::vector< double >>  mixing_matrix = {},
const bool  interpolate_power_spectrum = false,
const double  z_min_bin2 = -1.,
const double  z_max_bin2 = -1.,
const std::vector< double >  dN_par_bin2 = {} 
)

Set the data used to construct models of the angular power spectrum.

Parameters
cosmologythe cosmological model used to measure angular power spectrum
z_minthe minimum redshift of the first redshift slice or of the full integral in one bin case
z_maxthe maximum redshift of the first redshift slice or of the full integral in one bin case
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]
NL0 \(\rightarrow\) linear power spectrum; 1 \(\rightarrow\) non-linear power spectrum
norm0 \(\rightarrow\) don't normalise the power spectrum; 1 \(\rightarrow\) normalise the power spectrum; -1 \(\rightarrow\) normalise only if sigma8 is set
k_minminimum wave vector module up to which the power spectrum is computed in order to estimate the power spectrum normalisation; this parameter is used only if either norm=1, or norm=-1 and sigma8 is set
k_maxmaximum wave vector module up to which the power spectrum is computed to estimate the power spectrum normalisation; this parameter is used only if norm=1
dN_paroffset, slope and parameters of the dN/dz normalized distribution for the first redshift slice
fskythe fraction of the sky covered by the survey
llthe vector of the multipoles of the mixing matrix
mixing_matrixthe mixing matrix
interpolate_power_spectrumdefault false, true if you want to interpolate the 3D power spectrum on a grid (faster)
z_min_bin2the minimum redshift of the second redshift slice
z_max_bin2the maximum redshift of the second redshift slice
dN_par_bin2offset, slope and parameters of the dN/dz normalized distribution for the second redshift slice

Definition at line 76 of file Modelling_PowerSpectrum_Angular.cpp.

◆ set_model_limber() [1/2]

void cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::set_model_limber ( const std::vector< cbl::cosmology::CosmologicalParameter cosmo_param,
const std::vector< statistics::PriorDistribution cosmo_prior,
const statistics::PriorDistribution  bias_prior 
)

set the model to fit the angular power spectrum

the model is the following:

\[ C_l = \frac{b^2}{N^2}\int_{0}^{\infty} \frac{dN}{dz}\frac{dN}{dz} P_{mat} \left(\frac{l+1/2}{r(z)}\right) \frac{H(z)}{c}\frac{1}{r^2(z)} dz\]

the model has 1 parameters:

  • \( b \)

offset and slope of the dN/dz distribution are fixed by the user the angular power spectrum is computed using the input cosmological parameters

Parameters
cosmo_paramlist of cosmological parameter for the model
cosmo_priorprior for the cosmological parameters
bias_priorprior for the parameter \( b \)
Examples
model_power_spectrum_angular.cpp.

Definition at line 151 of file Modelling_PowerSpectrum_Angular.cpp.

◆ set_model_limber() [2/2]

void cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::set_model_limber ( const std::vector< cbl::cosmology::CosmologicalParameter cosmo_param,
const std::vector< statistics::PriorDistribution cosmo_prior,
const statistics::PriorDistribution  bias_prior,
const statistics::PriorDistribution  offset_slope_prior 
)

set the model to fit the angular power spectrum

the model is the following:

\[ C_l = \frac{b^2}{N^2}\int_0^\infty \frac{dN}{dz} \frac{dN}{dz} P_{mat} \left(\frac{l+1/2}{r(z)}\right) \frac{H(z)}{c}\frac{1}{r^2(z)} dz\]

the model has 3 parameters:

  • \( b \)
  • \( offset \)
  • \( slope \)

offset and slope reproduce the dN/dz distribution. The angular power spectrum is computed using the input cosmological parameters

Parameters
cosmo_paramlist of cosmological parameter for the model
cosmo_priorprior for the cosmological parameters
bias_priorprior for the parameter \( b \)
offset_slope_priorprior for the corralated parameter \( offset \) and \( slope \)

Definition at line 107 of file Modelling_PowerSpectrum_Angular.cpp.

◆ set_model_limber_cross()

void cbl::modelling::angularpk::Modelling_PowerSpectrum_angular::set_model_limber_cross ( const std::vector< cbl::cosmology::CosmologicalParameter cosmo_param,
const std::vector< statistics::PriorDistribution cosmo_prior,
const statistics::PriorDistribution  bias_prior_bin1,
const statistics::PriorDistribution  bias_prior_bin2 
)

set the model to fit the cross correlation angular power spectrum

the model is the following:

\[ C_l = \frac{b_i b_j}{N^2}\int_{0}^{\infty} \frac{dN_i}{dz}\frac{dN_j}{dz} P_{mat} \left(\frac{l+1/2}{r(z)}\right) \frac{H(z)}{c}\frac{1}{r^2(z)} dz\]

the model has 1 parameters:

  • \( b \)

offset and slope of the dN/dz distribution are fixed by the user the angular power spectrum is computed using the input cosmological parameters

Parameters
cosmo_paramlist of cosmological parameter for the model
cosmo_priorprior for the cosmological parameters
bias_prior_bin1prior for the parameter \( b_i \)
bias_prior_bin2prior for the parameter \( b_j \)

Definition at line 187 of file Modelling_PowerSpectrum_Angular.cpp.


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