Class mcmc_stepper_base (o2scl)

O2scl : Class List

template<class func_t, class data_t, class vec_t>
class mcmc_stepper_base

Stepper for o2scl::mcmc_para_base [pure virtual].

The user-specified function, should have a signature similar to

int f(size_t nv, const vec_t &x, double log_wgt,
data_t &dat)
where nv is the number of parameters, x is the vector of parameters, log_wgt is the log likelihood, and dat is the output data object. A return value of zero indicates success, while any return value other than zero indicates failure.

Subclassed by o2scl::mcmc_stepper_hmc< func_t, data_t, vec_t, grad_t, vec_bool_t >, o2scl::mcmc_stepper_mh< func_t, data_t, vec_t, mat_t, prop_t >, o2scl::mcmc_stepper_rw< func_t, data_t, vec_t >

Public Functions

inline mcmc_stepper_base()
inline virtual void write_params(o2scl_hdf::hdf_file &hf)

Write stepper parameters to the HDF5 file.

virtual const char *step_type() = 0

Stepper type.

inline void check_bounds(size_t i_thread, size_t n_params, vec_t &v, const vec_t &low, const vec_t &high, int &func_ret, int verbose)

Check that v is between low and high.

This function checks that the parameters are within limits. If they are not, then func_ret is set to mcmc_skip. Otherwise, func_ret is unchanged. If verbose is greater than or equal to 3, then a out-of-bounds warning is printed to the screen. Generally, if a point is out of bounds, this just means that the MCMC algorithm will reject this point as if it had a very small likelihood.

virtual void step(size_t i_thread, size_t n_params, func_t &f, const vec_t &current, vec_t &next, double w_current, double &w_next, const vec_t &low, const vec_t &high, int &func_ret, bool &accept, data_t &dat, rng<> &r, int verbose) = 0

Construct a step.

This function constructs next and w_next, the next point and log weight in parameter space. The objective function f is then evaluated at the new point, the return value is placed in func_ret, and the step acceptance or rejection is stored in accept.

inline virtual ~mcmc_stepper_base()

Protected Static Attributes

static const int mcmc_done = -10

Integer to indicate completion.

static const int mcmc_skip = -20

Integer to indicate rejection.