![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class Modelling_PowerSpectrum_angular. More...
#include <Modelling_PowerSpectrum_Angular.h>
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... | |
![]() | |
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... | |
Protected Attributes | |
std::shared_ptr< modelling::angularpk::STR_data_model > | m_data_model |
the container of parameters for angular power spectrum 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 | |
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 | |
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
Definition at line 61 of file Modelling_PowerSpectrum_Angular.h.
|
inline |
constructor
Pow | the angular power spectrum to model |
Definition at line 84 of file Modelling_PowerSpectrum_Angular.h.
|
inline |
constructor
dataset | the dataset containing the angular power spectrum to model |
Definition at line 93 of file Modelling_PowerSpectrum_Angular.h.
|
inline |
get the member m_data_model
Definition at line 198 of file Modelling_PowerSpectrum_Angular.h.
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.
cosmology | the cosmological model used to measure angular power spectrum |
z_min | the minimum redshift of the first redshift slice or of the full integral in one bin case |
z_max | the maximum redshift of the first redshift slice or of the full integral in one bin case |
method_Pk | method 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] |
NL | 0 \(\rightarrow\) linear power spectrum; 1 \(\rightarrow\) non-linear power spectrum |
norm | 0 \(\rightarrow\) don't normalise the power spectrum; 1 \(\rightarrow\) normalise the power spectrum; -1 \(\rightarrow\) normalise only if sigma8 is set |
k_min | minimum 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_max | maximum 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_par | offset, slope and parameters of the dN/dz normalized distribution for the first redshift slice |
fsky | the fraction of the sky covered by the survey |
ll | the vector of the multipoles of the mixing matrix |
mixing_matrix | the mixing matrix |
interpolate_power_spectrum | default false, true if you want to interpolate the 3D power spectrum on a grid (faster) |
Definition at line 48 of file Modelling_PowerSpectrum_Angular.cpp.
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.
cosmology | the cosmological model used to measure angular power spectrum |
z_min | the minimum redshift of the first redshift slice or of the full integral in one bin case |
z_max | the maximum redshift of the first redshift slice or of the full integral in one bin case |
method_Pk | method 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] |
NL | 0 \(\rightarrow\) linear power spectrum; 1 \(\rightarrow\) non-linear power spectrum |
norm | 0 \(\rightarrow\) don't normalise the power spectrum; 1 \(\rightarrow\) normalise the power spectrum; -1 \(\rightarrow\) normalise only if sigma8 is set |
k_min | minimum 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_max | maximum 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_par | offset, slope and parameters of the dN/dz normalized distribution for the first redshift slice |
fsky | the fraction of the sky covered by the survey |
ll | the vector of the multipoles of the mixing matrix |
mixing_matrix | the mixing matrix |
interpolate_power_spectrum | default false, true if you want to interpolate the 3D power spectrum on a grid (faster) |
z_min_bin2 | the minimum redshift of the second redshift slice |
z_max_bin2 | the maximum redshift of the second redshift slice |
dN_par_bin2 | offset, slope and parameters of the dN/dz normalized distribution for the second redshift slice |
Definition at line 76 of file Modelling_PowerSpectrum_Angular.cpp.
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:
offset and slope of the dN/dz distribution are fixed by the user the angular power spectrum is computed using the input cosmological parameters
cosmo_param | list of cosmological parameter for the model |
cosmo_prior | prior for the cosmological parameters |
bias_prior | prior for the parameter \( b \) |
Definition at line 151 of file Modelling_PowerSpectrum_Angular.cpp.
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:
offset and slope reproduce the dN/dz distribution. The angular power spectrum is computed using the input cosmological parameters
cosmo_param | list of cosmological parameter for the model |
cosmo_prior | prior for the cosmological parameters |
bias_prior | prior for the parameter \( b \) |
offset_slope_prior | prior for the corralated parameter \( offset \) and \( slope \) |
Definition at line 107 of file Modelling_PowerSpectrum_Angular.cpp.
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:
offset and slope of the dN/dz distribution are fixed by the user the angular power spectrum is computed using the input cosmological parameters
cosmo_param | list of cosmological parameter for the model |
cosmo_prior | prior for the cosmological parameters |
bias_prior_bin1 | prior for the parameter \( b_i \) |
bias_prior_bin2 | prior for the parameter \( b_j \) |
Definition at line 187 of file Modelling_PowerSpectrum_Angular.cpp.