KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Abstract_mh_step< Model, Proposer > Class Template Referenceabstract

#include <sample_step.h>

Inheritance diagram for Abstract_mh_step< Model, Proposer >:
Basic_mh_step< Model, Proposer > Annealing_mh_step< Model, Proposer >

Public Types

typedef Model_evaluator< Model >
::Type 
Target_distribution
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((BaseModel< Model >))
 
Step_log< Model > 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. More...
 
virtual Step_log< Model > operator() (Model &m, double lt_m) const
 Runs a step of Metropolis-Hastings on a model m. More...
 
virtual double get_temperature () const
 
virtual ~Abstract_mh_step ()
 
virtual Mh_proposal_result propose (const Model &m, Model &m_p) const =0
 Propose a new model. More...
 
virtual double l_target (const Model &m) const =0
 Evaluate the log-target distribution for the given model. More...
 
virtual void on_accept () const
 
virtual void on_reject () const
 

Protected Member Functions

virtual bool record_extra () const
 

Protected Attributes

boost::optional< Model > tmp_model_
 

Detailed Description

template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
class Abstract_mh_step< Model, Proposer >

Template Parameters
ModelThe 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.

Member Typedef Documentation

template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
typedef Model_evaluator<Model>::Type Abstract_mh_step< Model, Proposer >::Target_distribution

Constructor & Destructor Documentation

template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
virtual Abstract_mh_step< Model, Proposer >::~Abstract_mh_step ( )
inlinevirtual

Member Function Documentation

template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
Abstract_mh_step< Model, Proposer >::BOOST_CONCEPT_ASSERT ( (BaseModel< Model >)  )
template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
virtual double Abstract_mh_step< Model, Proposer >::get_temperature ( ) const
inlinevirtual
template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
virtual double Abstract_mh_step< Model, Proposer >::l_target ( const Model &  m) const
pure virtual
template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
virtual void Abstract_mh_step< Model, Proposer >::on_accept ( ) const
inlinevirtual
template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
virtual void Abstract_mh_step< Model, Proposer >::on_reject ( ) const
inlinevirtual
template<typename Model, typename Proposer >
Step_log< Model > Abstract_mh_step< Model, Proposer >::operator() ( Model &  m,
double  lt_m 
) const
virtual

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 = typename Mh_model_proposer<Model>::Type>
virtual Mh_proposal_result Abstract_mh_step< Model, Proposer >::propose ( const Model &  m,
Model &  m_p 
) const
pure virtual
template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
virtual bool Abstract_mh_step< Model, Proposer >::record_extra ( ) const
inlineprotectedvirtual

returns true if the step should store intermediate values and return them in the Step_log. Useful for debugging, but incurs a small performance penalty.

Reimplemented in Basic_mh_step< Model, Proposer_type >, Basic_mh_step< kjb::Vector >, Basic_mh_step< VectorModel, Mv_gaussian_proposer< VectorModel > >, Basic_mh_step< SimpleVector >, and Basic_mh_step< Model, Proposer >.

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_probThe acceptance probability of the proposed model
proposed_stateAn 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.

Member Data Documentation

template<typename Model, typename Proposer = typename Mh_model_proposer<Model>::Type>
boost::optional<Model> Abstract_mh_step< Model, Proposer >::tmp_model_
mutableprotected

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