![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class Modelling_Distribution. More...
#include <Modelling_Distribution.h>
Public Member Functions | |
Constructors/destructors | |
Modelling_Distribution ()=default | |
default constuctor | |
Modelling_Distribution (const std::shared_ptr< cbl::data::Data > dataset) | |
constuctor More... | |
virtual | ~Modelling_Distribution ()=default |
default destructor | |
Member functions used to set the model parameters | |
void | set_model_Distribution (const statistics::PriorDistribution mean_prior, const statistics::PriorDistribution std_prior, const std::string mean_name, const std::string std_name) |
set the parameters of a Gaussian PDF More... | |
void | set_model_Distribution (const double k, const statistics::PriorDistribution mean_prior, const statistics::PriorDistribution std0_prior, const std::string mean_name, const std::string std0_name, const std::string std_name) |
set the parameters of a Gaussian PDF, where the standard deviation, \(\sigma\), is expressed as 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 | |
STR_Distr_model | m_data_model |
the container of fixed parameters | |
![]() | |
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_Distribution.
Modelling_Distribution.h "Headers/Modelling_Distribution.h"
This file defines the interface of the base class Modelling_Distribution, used for modelling any kind of statistical distribution.
Definition at line 89 of file Modelling_Distribution.h.
|
inline |
constuctor
dataset | the dataset containing x, data and errors |
Definition at line 113 of file Modelling_Distribution.h.
void cbl::modelling::distribution::Modelling_Distribution::set_model_Distribution | ( | const double | k, |
const statistics::PriorDistribution | mean_prior, | ||
const statistics::PriorDistribution | std0_prior, | ||
const std::string | mean_name, | ||
const std::string | std0_name, | ||
const std::string | std_name | ||
) |
set the parameters of a Gaussian PDF, where the standard deviation, \(\sigma\), is expressed as
\(\sigma=\sigma_0k,\)
where \(k\) is fixed, \(\sigma_0\) is a base parameter, and \(\sigma\) is a derived parameter.
k | the value of \(k\) |
mean_prior | prior on the mean |
std0_prior | prior on \(\sigma_0\) |
mean_name | string identifying the mean |
std0_name | string identifying \(\sigma_0\) |
std_name | string identifying \(\sigma\) |
Definition at line 70 of file Modelling_Distribution.cpp.
void cbl::modelling::distribution::Modelling_Distribution::set_model_Distribution | ( | const statistics::PriorDistribution | mean_prior, |
const statistics::PriorDistribution | std_prior, | ||
const std::string | mean_name, | ||
const std::string | std_name | ||
) |
set the parameters of a Gaussian PDF
mean_prior | prior on the mean |
std_prior | prior on the standard deviation |
mean_name | string identifying the mean |
std_name | string identifying the standard deviation |
Definition at line 46 of file Modelling_Distribution.cpp.