Class fit_bayes (o2scl)

O2scl : Class List

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

Fit a function to data using Bayesian methods.

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?

Idea for Future:

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

Idea for Future:

Build upon gen_fit_funct instead of fit_funct?

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 Functions

fit_bayes()
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.

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)

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.

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

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.

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.

Public Members

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 Functions

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.