![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
#include "Headers/Model.h"
Public Member Functions | |
Dim | dimension () const |
return the model dimension More... | |
void | set_function (const model_function_1D function) |
set the model function, for Model1D More... | |
void | set_function (const std::vector< double >(*function)(const std::vector< double > xx, std::vector< double > &val)) |
set the model function, for Model1D More... | |
void | set_function (const model_function_2D function) |
set the model function, for Model2D More... | |
void | set_inputs (std::shared_ptr< void > inputs) |
set the model inputs More... | |
void | set_parameters (const std::shared_ptr< ModelParameters > parameters) |
set the model parameters More... | |
void | set_parameters (const size_t nparameters, std::vector< ParameterType > parameterTypes, std::vector< std::string > parameterNames) |
set the model parameters More... | |
std::shared_ptr< void > | inputs () |
return the model inputs More... | |
std::shared_ptr< ModelParameters > | parameters () |
return the model parameters More... | |
std::vector< std::vector< double > > | operator() (const std::vector< std::vector< double >> xx, std::vector< double > ¶meters) const |
evalueate the model function at xx, for Model1D More... | |
virtual double | operator() (const double xx, std::vector< double > ¶meters) const |
evaluate the model function at xx, for Model1D More... | |
virtual std::vector< double > | operator() (const std::vector< double > xx, std::vector< double > ¶meters) const |
evaluate the model function at xx, for Model1D More... | |
virtual double | operator() (const double xx, const double yy, std::vector< double > ¶meters) const |
evaluate the model function at xx, yy, for Model2D More... | |
virtual std::vector< std::vector< double > > | operator() (const std::vector< double > xx, const std::vector< double > yy, std::vector< double > ¶meters) const |
evaluate the model function at xx, yy, for Model2D More... | |
void | stats_from_chains (const std::vector< std::vector< double >> xx, std::vector< std::vector< double >> &median_model, std::vector< std::vector< double >> &low_model, std::vector< std::vector< double >> &up_model, const int start=0, const int thin=1) |
compute the median and percentiles of the model from MCMC chains More... | |
virtual void | stats_from_chains (const std::vector< double > xx, std::vector< double > &median_model, std::vector< double > &low_model, std::vector< double > &up_model, const int start=0, const int thin=1) |
compute the median and percentiles of the model from MCMC chains More... | |
virtual void | stats_from_chains (const std::vector< double > xx, const std::vector< double > yy, std::vector< std::vector< double >> &median_model, std::vector< std::vector< double >> &low_model, std::vector< std::vector< double >> &up_model, const int start=0, const int thin=1) |
compute the median and percentiles of the model from MCMC chains More... | |
virtual void | write (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 (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_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 likelihood maximization More... | |
virtual void | write_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_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_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... | |
Constructors/destructors | |
Model ()=default | |
default constructor | |
Model (const int nparameters, std::vector< ParameterType > parameterTypes, std::vector< std::string > parameterNames, const std::shared_ptr< void > inputs) | |
constructor More... | |
virtual | ~Model ()=default |
default destructor | |
Protected Attributes | |
std::shared_ptr< void > | m_inputs |
inputs of the model | |
std::shared_ptr< ModelParameters > | m_parameters |
parameters of the model | |
model_function_generic | m_function |
the model function | |
Dim | m_dimension |
the model dimension | |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
evaluate the model function at xx, yy, for Model2D
xx | the positions at which the model is computed |
yy | the positions at which the model is computed |
parameters | vector containing the model parameters |
Reimplemented in cbl::statistics::Model2D.
|
inlinevirtual |
evaluate the model function at xx, for Model1D
xx | the positions at which the model is computed |
parameters | vector containing the model parameters |
Reimplemented in cbl::statistics::Model1D.
|
inlinevirtual |
evaluate the model function at xx, yy, for Model2D
xx | vector containing the positions at which the model is computed |
yy | vector containing the positions at which the model is computed |
parameters | vector containing the model parameters |
Reimplemented in cbl::statistics::Model2D.
|
inlinevirtual |
evaluate the model function at xx, for Model1D
xx | vector containing the positions at which the model is computed |
parameters | vector containing the model parameters |
Reimplemented in cbl::statistics::Model1D.
vector< vector< double > > cbl::statistics::Model::operator() | ( | const std::vector< std::vector< double >> | xx, |
std::vector< double > & | parameters | ||
) | const |
|
inline |
return the model parameters
|
inline |
|
inline |
|
inline |
|
inline |
void cbl::statistics::Model::set_parameters | ( | const size_t | nparameters, |
std::vector< ParameterType > | parameterTypes, | ||
std::vector< std::string > | parameterNames | ||
) |
|
inline |
|
inlinevirtual |
compute the median and percentiles of the model from MCMC chains
xx | vector of points at which the model is computed, first axis |
yy | vector of points at which the model is computed, second axis |
median_model | the median model |
low_model | the model at 16th percentile |
up_model | the model at 84th percentile |
start | the starting position for each chain |
thin | the position step |
Reimplemented in cbl::statistics::Model2D.
|
inlinevirtual |
compute the median and percentiles of the model from MCMC chains
xx | vector of points at which the model is computed, |
median_model | the median model |
low_model | the model at 16th percentile |
up_model | the model at 84th percentile |
start | the starting position for each chain |
thin | the position step |
Reimplemented in cbl::statistics::Model1D.
void cbl::statistics::Model::stats_from_chains | ( | const std::vector< std::vector< double >> | xx, |
std::vector< std::vector< double >> & | median_model, | ||
std::vector< std::vector< double >> & | low_model, | ||
std::vector< std::vector< double >> & | up_model, | ||
const int | start = 0 , |
||
const int | thin = 1 |
||
) |
compute the median and percentiles of the model from MCMC chains
xx | vector of points at which the model is computed, |
median_model | the median model |
low_model | the model at 16th percentile |
up_model | the model at 84th percentile |
start | the starting position for each chain |
thin | the position step |
|
inlinevirtual |
write the model at xx for given parameters
output_dir | the output directory |
output_file | the output file |
xx | vector of points at which the model is computed, |
parameters | vector containing the input parameters used to compute the model; if this vector is not provided, the model will be computed using the best-fit parameters |
Reimplemented in cbl::statistics::Model1D.
|
inlinevirtual |
write the model at xx, yy for given parameters
output_dir | the output directory |
output_file | the output file |
xx | vector of points at which the model is computed, first axis |
yy | vector of points at which the model is computed, second axis |
parameters | vector containing the input parameters used to compute the model; if this vector is not provided, the model will be computed using the best-fit parameters |
Reimplemented in cbl::statistics::Model2D.
|
inlinevirtual |
write the model at xx with best-fit parameters obtained from likelihood maximization
output_dir | the output directory |
output_file | the output file |
xx | vector of points at which the model is computed |
Reimplemented in cbl::statistics::Model1D.
|
inlinevirtual |
write the model at xx, yy with best-fit parameters obtained from likelihood maximization
output_dir | the output directory |
output_file | the output file |
xx | vector of points at which the model is computed, first axis |
yy | vector of points at which the model is computed, second axis |
Reimplemented in cbl::statistics::Model2D.
|
inlinevirtual |
write the model at xx computing 16th, 50th and 84th percentiles from the chains.
output_dir | the output directory |
output_file | the output file |
xx | vector of points at which the model is computed, |
start | the starting position for each chain |
thin | the position step |
Reimplemented in cbl::statistics::Model1D.
|
inlinevirtual |
write the model at xx, yy computing 16th, 50th and 84th percentiles from the chains.
output_dir | the output directory |
output_file | the output file |
xx | vector of points at which the model is computed, first axis |
yy | vector of points at which the model is computed, second axis |
start | the starting position for each chain |
thin | the position step |
Reimplemented in cbl::statistics::Model2D.