48 std::vector<std::shared_ptr<statistics::Posterior>> posteriors(modelling.size());
49 for (
size_t i=0; i<modelling.size(); i++) {
50 modelling[i]->m_set_posterior(321);
51 auto posterior_ptr = modelling[i]->posterior();
52 posteriors[i] = std::move(posterior_ptr);
54 m_combined_posterior = make_shared<statistics::CombinedPosterior>(
statistics::CombinedPosterior(posteriors, repeated_par, common_repeated_par));
61 cbl::modelling::CombinedModelling::CombinedModelling (std::vector<std::vector<std::shared_ptr<modelling::Modelling>>> modelling, std::vector<std::shared_ptr<data::CovarianceMatrix>> covariance,
const std::vector<cbl::statistics::LikelihoodType> likelihood_types,
const std::vector<std::string> repeated_par,
const std::vector<std::vector<std::vector<int>>> common_repeated_par,
const std::vector<std::shared_ptr<cosmology::SuperSampleCovariance>> SSC)
63 std::vector<std::vector<std::shared_ptr<statistics::Posterior>>> posteriors(modelling.size());
64 for (
size_t i=0; i<modelling.size(); i++) {
65 posteriors[i].resize(modelling[i].size());
66 for (
size_t j=0; j<modelling[i].size(); j++) {
67 modelling[i][j]->m_set_posterior(321);
68 auto posterior_ptr = modelling[i][j]->posterior();
69 posteriors[i][j] = std::move(posterior_ptr);
72 m_combined_posterior = make_shared<statistics::CombinedPosterior>(
statistics::CombinedPosterior(posteriors, covariance, likelihood_types, repeated_par, common_repeated_par, SSC));
81 m_combined_posterior->maximize(start, max_iter, tol, epsilon);
90 m_combined_posterior->initialize_chains(chain_size, nwalkers);
91 m_combined_posterior->sample_stretch_move(aa, parallel);
100 m_combined_posterior->initialize_chains(chain_size, n_walkers, radius, start, max_iter, tol, epsilon);
101 m_combined_posterior->sample_stretch_move(aa, parallel);
110 m_combined_posterior->initialize_chains(chain_size, nwalkers, input_dir, input_file, seed);
111 m_combined_posterior->sample_stretch_move(aa, parallel);
120 m_combined_posterior->write_results(output_dir, root_file, start, thin, nbins, fits, compute_mode, ns);
129 m_combined_posterior->write_model_from_chain(output_dir, output_file, start, thin, xx, yy);
The class CombinedModelling.
void sample_combined_posterior(const int chain_size, const int nwalkers, const double aa=2, const bool parallel=true)
sample the posterior, initializing the chains by drawing from the prior distributions
CombinedModelling()=default
default constuctor
void write_combined_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
void write_model_from_combined_chain(const std::string output_dir, const std::string output_file, const int start, const int thin, const std::vector< double > xx={}, const std::vector< double > yy={})
write the model computing 16th, 50th and 84th percentiles from the MCMC
void maximize_combined_posterior(const std::vector< double > start, const unsigned int max_iter=10000, const double tol=1.e-6, const double epsilon=1.e-3)
function that maximizes the combined posterior, finds the best-fit parameters and stores them in the ...
The class CombinedPosterior.
The global namespace of the CosmoBolognaLib