Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
o2scl::fit_bayes< fit_func_t, multi_func_t, vec_t > Class Template Reference

Fit a function to data using Bayesian methods. More...

#include <fit_bayes.h>

Public Types

typedef boost::numeric::ublas::vector< double > ubvector
 
typedef boost::numeric::ublas::matrix< double > ubmatrix
 
typedef boost::numeric::ublas::vector< int > ubvector_int
 

Public Member Functions

virtual void evidence (size_t ndat, vec_t &xdat, vec_t &ydat, vec_t &yerr, size_t npar, vec_t &plo2, vec_t &phi2, multi_func_t &prior_fun, double &evi, double &err)
 Compute the evidence.
 
virtual double weight_fun (size_t ndat, const vec_t &xdat, const vec_t &ydat, const vec_t &yerr, size_t npar, const vec_t &par)
 The weight function (based on a $ \chi^2 $ distribution)
 
virtual int fit (size_t ndat, vec_t &xdat, vec_t &ydat, vec_t &yerr, size_t npar, vec_t &plo2, vec_t &pmax, vec_t &phi2, vec_t &plo_err, vec_t &pmax_err, vec_t &phi_err, fit_func_t &fitfun, multi_func_t &prior_fun)
 Fit ndat data points in xdat and ydat with errors yerr to function fitfun with npar parameters. More...
 
virtual int fit_hist (size_t ndat, vec_t &xdat, vec_t &ydat, vec_t &yerr, size_t npar, vec_t &plo2, vec_t &phi2, std::vector< hist > &par_hist, fit_func_t &fitfun, multi_func_t &prior_fun)
 Desc. More...
 

Public Attributes

size_t n_warm_up
 Number of warmup iterations (default 100)
 
size_t n_iter
 Number of total iterations (default 1000)
 
size_t hsize
 Histogram size (default 20)
 
size_t nmeas
 Number of measurements (default 20)
 
multi_func_t * pri
 Prior distribution.
 
rng_gsl gr
 Random number generator.
 
mcarlo_vegas def_inte
 Default Monte Carlo integrator.
 

Protected Member Functions

virtual double integrand (size_t npar, const vec_t &par)
 The integrand for the evidence.
 

Protected Attributes

fit_func_t * ff
 User-specified function.
 
size_t lndat
 Number of data points.
 
vec_t * lxdat
 X-values.
 
vec_t * lydat
 Y-values.
 
vec_t * lyerr
 Y-errors.
 

Detailed Description

template<class fit_func_t = fit_funct11, class multi_func_t = uniform_prior<>, class vec_t = boost::numeric::ublas::vector<double>>
class o2scl::fit_bayes< fit_func_t, multi_func_t, vec_t >

This class is experimental.

This class uses Markov Chain Monte Carlo (MCMC) and marginal estimation to give a probability distribution for parameters in a fit.

Idea for Future:

Also make weight_fun() an object of type multi_func_t?

Offer two ways to do the evidence: direct MC or the interpolation method from SLB13

Build upon gen_fit_funct instead of fit_funct?

Definition at line 77 of file fit_bayes.h.

Member Function Documentation

◆ fit()

template<class fit_func_t = fit_funct11, class multi_func_t = uniform_prior<>, class vec_t = boost::numeric::ublas::vector<double>>
virtual int o2scl::fit_bayes< fit_func_t, multi_func_t, vec_t >::fit ( size_t  ndat,
vec_t &  xdat,
vec_t &  ydat,
vec_t &  yerr,
size_t  npar,
vec_t &  plo2,
vec_t &  pmax,
vec_t &  phi2,
vec_t &  plo_err,
vec_t &  pmax_err,
vec_t &  phi_err,
fit_func_t &  fitfun,
multi_func_t &  prior_fun 
)
inlinevirtual

The initial values of the parameters should be specified in par.

Definition at line 178 of file fit_bayes.h.

◆ fit_hist()

template<class fit_func_t = fit_funct11, class multi_func_t = uniform_prior<>, class vec_t = boost::numeric::ublas::vector<double>>
virtual int o2scl::fit_bayes< fit_func_t, multi_func_t, vec_t >::fit_hist ( size_t  ndat,
vec_t &  xdat,
vec_t &  ydat,
vec_t &  yerr,
size_t  npar,
vec_t &  plo2,
vec_t &  phi2,
std::vector< hist > &  par_hist,
fit_func_t &  fitfun,
multi_func_t &  prior_fun 
)
inlinevirtual

For each measurement block, this function collects the data for all the parameters into 1d histogram objects. Then, at the end of the block, the histogram information is added to a hist object for each parameter.

Definition at line 334 of file fit_bayes.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).