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

The class LikelihoodParameters. More...

#include <LikelihoodParameters.h>

Inheritance diagram for cbl::statistics::LikelihoodParameters:
Collaboration diagram for cbl::statistics::LikelihoodParameters:

Public Member Functions

void reset () override
 reset the parameter vectors
 
std::string status (const int p) const
 return the model parameter status More...
 
std::vector< std::string > status () const
 return all the model parameter status More...
 
Constructors/destructors
 LikelihoodParameters ()=default
 default constructor
 
 LikelihoodParameters (const size_t nparameters, std::vector< ParameterType > parameterTypes, std::vector< std::string > parameterNames)
 constructor for LikelihoodParameters More...
 
 ~LikelihoodParameters ()=default
 default destructor
 
Member functions used to set private/protected of the ModelParameters
size_t nparameters_free () const override
 return the number of free parameters More...
 
std::vector< unsigned int > free_parameter () const
 return the private member m_free_parameter More...
 
size_t nparameters_fixed () const override
 return the number of fixed parameters More...
 
std::vector< unsigned int > fixed_parameter () const
 return the private member m_fixed_parameter More...
 
std::vector< double > full_parameter (const std::vector< double > parameter_value) const override
 return all the model parameter More...
 
void set_parameters (const size_t nparameters, std::vector< ParameterType > parameterTypes, std::vector< std::string > parameterNames) override
 set the parameter More...
 
Member functions to manage fixed/free parameters
void free (const int p) override
 set m_fixed to false; More...
 
void fix (const int p, const double value) override
 fix the parameter at the input value; More...
 
void fix_at_bestfit (const int p) override
 fix the parameter at the bestfit value, contained in m_bestfit_value; More...
 
double bestfit_value (const int p) const override
 get the protected member m_value More...
 
std::vector< double > bestfit_value () const override
 get the protected member m_value More...
 
void set_bestfit_values (const std::vector< double > bestfit_value) override
 set the protected member m_bestfit_value More...
 
void write_bestfit_info () override
 write the best fit info
 
- Public Member Functions inherited from cbl::statistics::ModelParameters
virtual void set_parameter_covariance (const int start=0, const int thin=1)
 set the internal method m_parameter_covariance More...
 
virtual double parameter_covariance (const int i, const int j) const
 return the protected member m_parameter_covariance More...
 
virtual std::vector< std::vector< double > > parameter_covariance () const
 return the protected member m_parameter_covariance More...
 
virtual void show_results (const int start, const int thin, const int nbins, const int seed=34121, const bool show_mode=false, const int ns=-1, const int nb=-1, const std::vector< double > weight={})
 show the results on the standard output More...
 
virtual void write_results (const std::string dir, const std::string file, const int start, const int thin, const int nbins, const int seed=34121, const bool compute_mode=false, const int ns=-1, const int nb=-1, const std::vector< double > weight={})
 store the results to file More...
 
virtual size_t chain_size () const
 return the private member m_chain_size More...
 
virtual size_t chain_nwalkers () const
 return the private member m_chain_nwalkers More...
 
virtual void set_chain (const size_t size, const size_t nwalkers)
 set the chain More...
 
virtual void reset_chain ()
 reset the chain using m_size and m_nwalkers
 
virtual void expand_chain (const int append)
 expand the already existing chain More...
 
virtual double chain_value (const int param, const int pos, const int ww) const
 return the private member m_chain_values at the pos step for the ww-th walker, for the chosen parameter More...
 
virtual std::vector< double > chain_value_parameters (const int pos, const int ww) const
 return the private member m_values at the pp-th step for the ww-th step for all the parameters More...
 
virtual std::vector< double > parameter_chain_values (const int par, const int start=0, const int thin=1) const
 return all the chain values for a parameter More...
 
virtual void set_chain_value (const int param, const int pos, const int ww, const double value)
 set the private member m_chain_values at the pp-th step for the ww-th step More...
 
virtual void set_chain_values (const std::vector< std::vector< double >> values, const int nwalkers)
 set the chain values More...
 
virtual void set_chain_values (const std::vector< std::vector< std::vector< double >>> values)
 set the chain values More...
 
virtual void initialize_chain (const std::vector< std::vector< double >> values)
 initialize the chain values More...
 
virtual void initialize_chain_from_prior ()
 initialize the chain values random sampling the parameter priors
 
virtual void initialize_chain_ball (const std::vector< double > center, const double radius, const double seed)
 initialize the chain values More...
 
virtual void initialize_chain_ball_bestfit (const double radius, const double seed)
 initialize the chain values around bestfit values More...
 
 ModelParameters ()=default
 default constructor
 
 ModelParameters (const size_t nparameters, std::vector< ParameterType > parameterTypes, std::vector< std::string > parameterNames)
 constructor for ModelParameters More...
 
 ModelParameters (const size_t nparameters, std::vector< std::string > parameterNames)
 constructor for ModelParameters More...
 
 ~ModelParameters ()=default
 default destructor
 
size_t nparameters () const
 return the total number of parameters More...
 
size_t nparameters_base () const
 return the number of base parameters More...
 
std::vector< unsigned int > base_parameter () const
 return the private member m_base_parameters More...
 
size_t nparameters_derived () const
 return the number of derived parameters More...
 
size_t nparameters_correlated () const
 return the number of correlated parameters More...
 
std::vector< unsigned int > derived_parameter () const
 return the private member m_derived_parameter More...
 
ParameterType type (const int p) const
 return the model parameter type More...
 
std::vector< ParameterTypetype () const
 return all the model parameter names More...
 
std::string name (const int p) const
 return the model parameter name More...
 
std::vector< std::string > name () const
 return all the model parameter names More...
 
virtual void set_parameters (const size_t nparameters, std::vector< std::string > parameterNames)
 set the parameter More...
 
virtual void set_parameters (const size_t nparameters, const std::vector< std::shared_ptr< PriorDistribution >> priorDistributions, std::vector< ParameterType > parameterTypes, std::vector< std::string > parameterNames)
 set the parameter More...
 
virtual void set_bestfit_values (const int start, const int thin, const int nbins, const int seed)
 set the protected member m_bestfit_value More...
 
virtual void set_prior_distribution (const int p, const std::shared_ptr< PriorDistribution > priorDistribution)
 set the prior distribution for the p-th parameter More...
 
virtual void set_prior_distribution (const std::vector< std::shared_ptr< PriorDistribution >> priorDistributions)
 set the prior distributions for the parameters More...
 
virtual void set_prior_distribution_seed (const std::shared_ptr< random::UniformRandomNumbers_Int > ran_generator)
 set the prior distributions for the parameters More...
 
virtual std::shared_ptr< PriorDistributionprior_distribution (const int p) const
 get the prior distribution for the p-th parameter More...
 
virtual std::vector< std::shared_ptr< PriorDistribution > > prior_distribution () const
 get the prior distribution for the p-th parameter More...
 
virtual std::shared_ptr< Priorprior () const
 get the prior function More...
 
virtual void set_posterior_distribution (const int start, const int thin, const int nbins, const int seed=34121, const std::vector< double > weight={})
 set the prior distribution for the p-th parameter More...
 
virtual std::shared_ptr< PosteriorDistributionposterior_distribution (const int par) const
 get the posterior distribution for the chosen parameter More...
 

Protected Member Functions

void m_set_parameter_type () override
 private member to set the parameter types
 

Protected Attributes

std::vector< bool > m_parameter_isFixed
 false \(\rightarrow\) free parameter; true \(\rightarrow\) fixed parameters
 
size_t m_nparameters_free = 0
 the number of free parameters
 
size_t m_nparameters_fixed = 0
 the number of fixed parameters
 
std::vector< unsigned int > m_fixed_parameter
 the indexes of fixed parameters
 
std::vector< unsigned int > m_free_parameter
 the indexes of the free parameters
 
std::vector< double > m_parameter_fixed_value
 the model parameter fixed values
 
std::vector< double > m_parameter_bestfit_value
 the best-fit parameter values, i.e. the maxima of the likelihood
 
- Protected Attributes inherited from cbl::statistics::ModelParameters
std::vector< ParameterTypem_parameter_type
 model parameters
 
std::vector< std::string > m_parameter_name
 model parameter types
 
size_t m_nparameters = 0
 number of parameters
 
size_t m_nparameters_base = 0
 number of base parameters
 
size_t m_nparameters_derived = 0
 number of derived parameters
 
size_t m_nparameters_correlated = 0
 number of correlated parameters
 
std::vector< unsigned int > m_base_parameter
 indexes of base parameters
 
std::vector< unsigned int > m_derived_parameter
 indexes of the derived parameters
 

Detailed Description

The class LikelihoodParameters.

"Headers/LikelihoodParameters.h"

This class is used to define the model parameters

Definition at line 50 of file LikelihoodParameters.h.

Constructor & Destructor Documentation

◆ LikelihoodParameters()

cbl::statistics::LikelihoodParameters::LikelihoodParameters ( const size_t  nparameters,
std::vector< ParameterType parameterTypes,
std::vector< std::string >  parameterNames 
)

constructor for LikelihoodParameters

Parameters
nparametersthe number of parameters
parameterTypesthe parameter types
parameterNamesthe parameter names

Definition at line 194 of file LikelihoodParameters.cpp.

Member Function Documentation

◆ bestfit_value() [1/2]

vector< double > cbl::statistics::LikelihoodParameters::bestfit_value ( ) const
overridevirtual

get the protected member m_value

Returns
the parameter bestfit values

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 353 of file LikelihoodParameters.cpp.

◆ bestfit_value() [2/2]

double cbl::statistics::LikelihoodParameters::bestfit_value ( const int  p) const
overridevirtual

get the protected member m_value

Parameters
pthe p-th parameter
Returns
the bestfit value of the parameter

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 342 of file LikelihoodParameters.cpp.

◆ fix()

void cbl::statistics::LikelihoodParameters::fix ( const int  p,
const double  value 
)
overridevirtual

fix the parameter at the input value;

Parameters
pthe p-th parameter
valuethe input value

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 306 of file LikelihoodParameters.cpp.

◆ fix_at_bestfit()

void cbl::statistics::LikelihoodParameters::fix_at_bestfit ( const int  p)
overridevirtual

fix the parameter at the bestfit value, contained in m_bestfit_value;

Parameters
pthe p-th parameter

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 333 of file LikelihoodParameters.cpp.

◆ fixed_parameter()

std::vector<unsigned int> cbl::statistics::LikelihoodParameters::fixed_parameter ( ) const
inlinevirtual

return the private member m_fixed_parameter

Returns
the private member m_fixed_parameter

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 176 of file LikelihoodParameters.h.

◆ free()

void cbl::statistics::LikelihoodParameters::free ( const int  p)
overridevirtual

set m_fixed to false;

Parameters
pthe p-th parameter

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 280 of file LikelihoodParameters.cpp.

◆ free_parameter()

std::vector<unsigned int> cbl::statistics::LikelihoodParameters::free_parameter ( ) const
inlinevirtual

return the private member m_free_parameter

Returns
the private member m_free_parameter

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 161 of file LikelihoodParameters.h.

◆ full_parameter()

vector< double > cbl::statistics::LikelihoodParameters::full_parameter ( const std::vector< double >  parameter_value) const
overridevirtual

return all the model parameter

Parameters
parameter_valuevector of free parameter
Returns
all the parameter values

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 114 of file LikelihoodParameters.cpp.

◆ nparameters_fixed()

size_t cbl::statistics::LikelihoodParameters::nparameters_fixed ( ) const
overridevirtual

return the number of fixed parameters

Returns
the number of fixed parameters

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 212 of file LikelihoodParameters.cpp.

◆ nparameters_free()

size_t cbl::statistics::LikelihoodParameters::nparameters_free ( ) const
overridevirtual

return the number of free parameters

Returns
the number of free parameters

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 203 of file LikelihoodParameters.cpp.

◆ set_bestfit_values()

void cbl::statistics::LikelihoodParameters::set_bestfit_values ( const std::vector< double >  bestfit_value)
overridevirtual

set the protected member m_bestfit_value

Parameters
bestfit_valueparameter bestfit values

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 365 of file LikelihoodParameters.cpp.

◆ set_parameters()

void cbl::statistics::LikelihoodParameters::set_parameters ( const size_t  nparameters,
std::vector< ParameterType parameterTypes,
std::vector< std::string >  parameterNames 
)
overridevirtual

set the parameter

Parameters
nparametersthe number of parameters
parameterTypesthe parameter types
parameterNamesthe parameter names

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 221 of file LikelihoodParameters.cpp.

◆ status() [1/2]

vector< string > cbl::statistics::LikelihoodParameters::status ( ) const
virtual

return all the model parameter status

Returns
vector containing all the parameter statuss

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 83 of file LikelihoodParameters.cpp.

◆ status() [2/2]

string cbl::statistics::LikelihoodParameters::status ( const int  p) const
virtual

return the model parameter status

Parameters
pthe index of the parameter
Returns
the parameter status

Reimplemented from cbl::statistics::ModelParameters.

Definition at line 52 of file LikelihoodParameters.cpp.


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