CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::statistics::Model2D Class Reference

The class Model2D. More...

#include "Headers/Model2D.h"

Inheritance diagram for cbl::statistics::Model2D:
Collaboration diagram for cbl::statistics::Model2D:

Public Member Functions

void set_function (const model_function_2D function)
 set the model function More...
 
double operator() (const double xx, const double yy, std::vector< double > &parameters) const override
 evaluate the model function at xx, yy More...
 
std::vector< std::vector< double > > operator() (const std::vector< double > xx, const std::vector< double > yy, std::vector< double > &parameters) const override
 evaluate the model function at xx, yy More...
 
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) override
 compute the median and percentiles of the model from MCMC chains More...
 
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) override
 write the model at xx, yy for given parameters More...
 
void write_at_bestfit (const std::string output_dir, const std::string output_file, const std::vector< double > xx, const std::vector< double > yy) override
 write the model at xx, yy with best-fit parameters obtained from likelihood maximization
More...
 
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) override
 write the model at xx, yy computing 16th, 50th and 84th percentiles from the chains. More...
 
Constructors/destructors
 Model2D ()
 default constructor
 
 Model2D (model_function_2D function, const size_t nparameters, std::vector< ParameterType > parameterTypes={}, std::vector< std::string > parameterNames={}, std::shared_ptr< void > inputs=NULL)
 constructor More...
 
 ~Model2D ()=default
 default destructor
 
- Public Member Functions inherited from cbl::statistics::Model
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< ModelParametersparameters ()
 return the model parameters More...
 
std::vector< std::vector< double > > operator() (const std::vector< std::vector< double >> xx, std::vector< double > &parameters) const
 evalueate the model function at xx, for Model1D More...
 
virtual double operator() (const double xx, std::vector< double > &parameters) const
 evaluate the model function at xx, for Model1D More...
 
virtual std::vector< double > operator() (const std::vector< double > xx, std::vector< double > &parameters) const
 evaluate the model function at xx, for Model1D 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 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_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_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...
 
 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
 

Additional Inherited Members

- Protected Attributes inherited from cbl::statistics::Model
std::shared_ptr< void > m_inputs
 inputs of the model
 
std::shared_ptr< ModelParametersm_parameters
 parameters of the model
 
model_function_generic m_function
 the model function
 
Dim m_dimension
 the model dimension
 

Detailed Description

The class Model2D.

This class is used to define 2D models

Definition at line 60 of file Model2D.h.

Constructor & Destructor Documentation

◆ Model2D()

cbl::statistics::Model2D::Model2D ( model_function_2D  function,
const size_t  nparameters,
std::vector< ParameterType parameterTypes = {},
std::vector< std::string >  parameterNames = {},
std::shared_ptr< void >  inputs = NULL 
)
inline

constructor

Parameters
functionthe model function
nparametersthe number of parameters
parameterTypesthe parameter types
parameterNamesthe parameter names
inputslist of model inputs

Definition at line 91 of file Model2D.h.

Member Function Documentation

◆ operator()() [1/2]

double cbl::statistics::Model2D::operator() ( const double  xx,
const double  yy,
std::vector< double > &  parameters 
) const
inlineoverridevirtual

evaluate the model function at xx, yy

Parameters
xxthe positions at which the model is computed
yythe positions at which the model is computed
parametersvector containing the model parameters
Returns
vector containing model values

Reimplemented from cbl::statistics::Model.

Definition at line 123 of file Model2D.h.

◆ operator()() [2/2]

std::vector<std::vector<double> > cbl::statistics::Model2D::operator() ( const std::vector< double >  xx,
const std::vector< double >  yy,
std::vector< double > &  parameters 
) const
inlineoverridevirtual

evaluate the model function at xx, yy

Parameters
xxvector containing the positions at which the model is computed
yyvector containing the positions at which the model is computed
parametersvector containing the model parameters
Returns
vector containing model values

Reimplemented from cbl::statistics::Model.

Definition at line 142 of file Model2D.h.

◆ set_function()

void cbl::statistics::Model2D::set_function ( const model_function_2D  function)

set the model function

Parameters
functionthe model function

Definition at line 44 of file Model2D.cpp.

◆ stats_from_chains()

void cbl::statistics::Model2D::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 
)
overridevirtual

compute the median and percentiles of the model from MCMC chains

Parameters
xxvector of points at which the model is computed, first axis
yyvector of points at which the model is computed, second axis
median_modelthe median model
low_modelthe model at 16th percentile
up_modelthe model at 84th percentile
startthe starting position for each chain
thinthe position step

Reimplemented from cbl::statistics::Model.

Definition at line 56 of file Model2D.cpp.

◆ write()

void cbl::statistics::Model2D::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 
)
overridevirtual

write the model at xx, yy for given parameters

Parameters
output_dirthe output directory
output_filethe output file
xxvector of points at which the model is computed, first axis
yyvector of points at which the model is computed, second axis
parametersvector 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 from cbl::statistics::Model.

Definition at line 65 of file Model2D.cpp.

◆ write_at_bestfit()

void cbl::statistics::Model2D::write_at_bestfit ( const std::string  output_dir,
const std::string  output_file,
const std::vector< double >  xx,
const std::vector< double >  yy 
)
overridevirtual

write the model at xx, yy with best-fit parameters obtained from likelihood maximization

Parameters
output_dirthe output directory
output_filethe output file
xxvector of points at which the model is computed, first axis
yyvector of points at which the model is computed, second axis

Reimplemented from cbl::statistics::Model.

Definition at line 92 of file Model2D.cpp.

◆ write_from_chains()

void cbl::statistics::Model2D::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 
)
overridevirtual

write the model at xx, yy computing 16th, 50th and 84th percentiles from the chains.

Parameters
output_dirthe output directory
output_filethe output file
xxvector of points at which the model is computed, first axis
yyvector of points at which the model is computed, second axis
startthe starting position for each chain
thinthe position step

Reimplemented from cbl::statistics::Model.

Definition at line 102 of file Model2D.cpp.


The documentation for this class was generated from the following files: