CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
model_2pt_multipoles.cpp

This example shows how to model the multipoles of the two-point correlation function in redshift space

// ========================================================================================
// Example code: how to model the multipoles of the two-point correlation in redshift space
// ========================================================================================
int main () {
try {
// --------------------------------------------------------------------
// ---------------- set the cosmological model to Planck15 ------------
// --------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// ---------------- read the input catalogue (with observed coordinates: R.A., Dec, redshift) ----------------
// -----------------------------------------------------------------------------------------------------------
const std::string file_catalogue = "../input/cat.dat";
// --------------------------------------------------------------------------------------
// ---------------- construct the random catalogue (with cubic geometry) ----------------
// --------------------------------------------------------------------------------------
const double N_R = 10.; // random/data ratio
// --------------------------------------------------------------------------------------------
// ---------------- measure the multipoles of the two-point correlation function --------------
// --------------------------------------------------------------------------------------------
// output directory
const std::string dir = "../output/";
// binning parameters and output data
const double rMin = 10.; // minimum separation
const double rMax = 30.; // maximum separation
const int nbins = 5; // number of bins
const double shift = 0.5; // spatial shift used to set the bin centre
// measure the multipoles (using the direct estimator)
cbl::measure::twopt::TwoPointCorrelation_multipoles_direct TwoP_direct {catalogue, random_catalogue, cbl::BinType::_logarithmic_, rMin, rMax, nbins, shift};
TwoP_direct.measure(cbl::measure::ErrorType::_Poisson_, dir);
// store the output data
TwoP_direct.write(dir, "xil_direct.dat");
// ------------------------------------------------------------------------------------------
// ---------------- model the multipoles of the two-point correlation function --------------
// ------------------------------------------------------------------------------------------
// object used for modelling and set the data used to construct the model
auto ptr_TwoP = std::make_shared<cbl::measure::twopt::TwoPointCorrelation_multipoles_direct>(TwoP_direct);
// set the priors
const cbl::statistics::PriorDistribution alpha_perpendicular_prior {cbl::glob::DistributionType::_Constant_, 1.}; // constant prior
const cbl::statistics::PriorDistribution alpha_parallel_prior {cbl::glob::DistributionType::_Constant_, 1.}; // constant prior
const cbl::statistics::PriorDistribution SigmaNL_perpendicular_prior {cbl::glob::DistributionType::_Constant_, 0.}; // constant prior
const cbl::statistics::PriorDistribution SigmaNL_parallel_prior {cbl::glob::DistributionType::_Constant_, 0.}; // constant prior
const cbl::statistics::PriorDistribution fsigma8_prior {cbl::glob::DistributionType::_Uniform_, 0., 2.}; // Uniform prior for the f*sigma8
const cbl::statistics::PriorDistribution bsigma8_prior {cbl::glob::DistributionType::_Uniform_, 0., 2.}; // Uniform prior for the b*sigma8
const cbl::statistics::PriorDistribution SigmaS_prior {cbl::glob::DistributionType::_Uniform_, 0., 10.}; // Uniform prior for the SigmaS
// provide the cosmological model and the redshift
const double redshift = 1.;
model_multipoles.set_data_model(cosmology, redshift);
// set the scale range for the fit
const double xmin = 10., xmax = 50.;
model_multipoles.set_fit_range(xmin, xmax, 3);
// set the model for the full-shape analyses fo the clustering multipoles
model_multipoles.set_model_fullShape_DeWiggled(alpha_perpendicular_prior, alpha_parallel_prior, SigmaNL_perpendicular_prior, SigmaNL_parallel_prior, fsigma8_prior, bsigma8_prior, SigmaS_prior);
// set the likelihood type
// maximise the posterior
const std::vector<double> start = {0.2, 0.2, 1.};
model_multipoles.maximize_posterior(start);
// retrieve and show the best-fit parameter values
for (unsigned int i=0; i<model_multipoles.posterior()->parameters()->nparameters(); ++i)
std::cout << "the best-fit value of " << model_multipoles.posterior()->parameters()->name(i) << " is " << model_multipoles.posterior()->parameters()->bestfit_value(i) << std::endl;
}
catch(cbl::glob::Exception &exc) { std::cerr << exc.what() << std::endl; exit(1); }
return 0;
}
int main()
main function to create the logo of the CosmoBolognaLib
Definition: Logo.cpp:41
The class Modelling_TwoPointCorrelation_multipoles.
The class TwoPointCorrelation_multipoles_direct.
The class TwoPointCorrelation_multipoles_integrated.
The class Catalogue.
Definition: Catalogue.h:654
The class Cosmology.
Definition: Cosmology.h:277
The class Exception.
Definition: Exception.h:111
const char * what() const noexcept override
the error description
Definition: Exception.h:203
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
Definition: Modelling.cpp:124
std::shared_ptr< statistics::Posterior > posterior()
return the posterior parameters
Definition: Modelling.cpp:85
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
Definition: Modelling.cpp:177
void set_data_model(const cbl::cosmology::Cosmology cosmology, const double redshift, const std::string method_Pk="CAMB", const double sigmaNL_perp=0., const double sigmaNL_par=0., const bool NL=true, const double bias=1., const double pimax=40., const double r_min=1., const double r_max=350., const double k_min=1.e-4, const double k_max=100., const int step=500, const std::string output_dir=par::defaultString, const std::string output_root="test", const int norm=-1, const double aa=0., const bool GSL=true, const double prec=1.e-3, const std::string file_par=par::defaultString, const double Delta=200., const bool isDelta_critical=true, const std::vector< double > cluster_redshift={}, const std::vector< double > cluster_mass_proxy={}, const std::vector< double > cluster_mass_proxy_error={}, const std::string model_bias="Tinker", const std::string meanType="mean_bias", const int seed=666, const cbl::cosmology::Cosmology cosmology_mass={}, const std::vector< double > redshift_source={})
set the data used to construct generic models of the two-point correlation function
void set_model_fullShape_DeWiggled(const statistics::PriorDistribution alpha_perpendicular_prior={}, const statistics::PriorDistribution alpha_parallel_prior={}, const statistics::PriorDistribution SigmaNL_perpendicular_prior={}, const statistics::PriorDistribution SigmaNL_parallel_prior={}, const statistics::PriorDistribution fsigma8_prior={}, const statistics::PriorDistribution bsigma8_prior={}, const statistics::PriorDistribution SigmaS_prior={}, const bool compute_PkDM=true)
set the model to fit the full shape of the multipole moments of the two-point correlation function
void set_fit_range(const double xmin, const double xmax, const int nmultipoles=-1)
set the scale range used for the fit
The class PriorDistribution.
@ _createRandom_box_
random catalogue with cubic geometry (or parallelepiped) in comoving coordinates
@ _Planck15_
Planck collaboration 2015, paper XIII: Table 4, TT,TE,EE+lowP+lensing.
@ _Constant_
Constant function.
@ _Uniform_
Identity function.
@ _Poisson_
Poissonian error.
@ _Gaussian_Error_
Gaussian likelihood error.
@ _observed_
observed coordinates (R.A., Dec, redshift)
@ _logarithmic_
logarithmic binning