template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
class Abstract_mh_step< Model, Proposer >
- Template Parameters
-
Model | The model type. Must comply with BaseModel concept. |
Abstract_mh_step is a functor that runs a single step of metropolis hastings on a model.
This class implements the logic for one Metropolis Hastings algorithm step. A subclass need only define the model's target distribution and a proposal mechanism. That is, subclasses must implement get_log_target() and get_proposer().
Optimizations to speed up MH (caching, for example) can be done in the implementation of the proposer and the target distribution.
template<typename Model, typename Proposer >
Runs a step of Metropolis-Hastings on a model m.
If the step is rejected, m remains unchanged; if the step is accepted, m will hold the new state. Returns a structure describing the results of the step.
- Note
- This method uses swap(Model a, Model b), whose generalized implementation is very inefficient. For best performance, swap() should be specialized for Model.
template<typename Model, typename Proposer >
Step_log< Model > Abstract_mh_step< Model, Proposer >::run_step |
( |
Model & |
m, |
|
|
double |
lt_m, |
|
|
double & |
accept_prob, |
|
|
boost::optional< Model & > |
proposed_state_out = boost::none |
|
) |
| const |
Runs a step of Metropolis-Hastings on a model m.
If the step is rejected, m remains unchanged; if the step is accepted, m will hold the new state. Returns a structure describing the results of the step.
This three-parameter version also returns the acceptance probability, which is useful when implementing adaptive MH. If this isn't needed, using operator() is recommended.
- Parameters
-
accept_prob | The acceptance probability of the proposed model |
proposed_state | An output parameter that will receive a copy of the proposed state. If ommitted, no copy occurs. |
- Note
- This method uses swap(Model a, Model b), whose generalized implementation is very inefficient. For best performance, swap() should be specialized for Model.