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
Basic_mh_step< Model, Proposer_type > Class Template Reference

#include <sample_step.h>

Inheritance diagram for Basic_mh_step< Model, Proposer_type >:
Abstract_mh_step< Model, Proposer_type >

Public Types

typedef Abstract_mh_step
< Model, Proposer_type > 
Parent
 
typedef Parent::Target_distribution Target_distribution
 
typedef Proposer_type Proposer
 
- Public Types inherited from Abstract_mh_step< Model, Proposer_type >
typedef Model_evaluator< Model >
::Type 
Target_distribution
 

Public Member Functions

 Basic_mh_step (const Target_distribution &log_target, const Proposer_type &proposer)
 Initializes target and proposer functors (or functions) to the given arguments. More...
 
virtual ~Basic_mh_step ()
 Initializes target and proposer functors (or functions) to the given arguments. More...
 
virtual Mh_proposal_result propose (const Model &m, Model &m_p) const
 Assignment. More...
 
virtual double l_target (const Model &m) const
 Evaluate the log-target distribution for the given model. More...
 
void set_target (const Target_distribution &target)
 
void record_extra (bool enable)
 
void set_temperature (double T)
 
virtual double get_temperature () const
 
- Public Member Functions inherited from Abstract_mh_step< Model, Proposer_type >
 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 ~Abstract_mh_step ()
 
virtual void on_accept () const
 
virtual void on_reject () const
 

Protected Member Functions

virtual bool record_extra () const
 
Proposer_type & get_proposer_ ()
 

Protected Attributes

Target_distribution m_log_target
 
Proposer_type m_proposer
 
double m_temperature
 
bool m_record_extra
 
- Protected Attributes inherited from Abstract_mh_step< Model, Proposer_type >
boost::optional< Model > tmp_model_
 

Detailed Description

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
class Basic_mh_step< Model, Proposer_type >

Template Parameters
ModelThe model type. Must comply with BaseModel concept.

Basic_mh_step is a functor that runs a single step of metropolis hastings on a model.

This class is a subclass of the abstract class Abstract_mh_step. It implements the get_log_target and get_proposer member functions in the obvious way: it returns references to private members of the correct types. These members are initialized from references received in the constructor.

Member Typedef Documentation

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
typedef Abstract_mh_step<Model, Proposer_type> Basic_mh_step< Model, Proposer_type >::Parent
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
typedef Proposer_type Basic_mh_step< Model, Proposer_type >::Proposer
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
typedef Parent::Target_distribution Basic_mh_step< Model, Proposer_type >::Target_distribution

Constructor & Destructor Documentation

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
Basic_mh_step< Model, Proposer_type >::Basic_mh_step ( const Target_distribution log_target,
const Proposer_type &  proposer 
)
inline

Initializes target and proposer functors (or functions) to the given arguments.

Parameters
log_targetTarget_distribution object used to initialize internal target distribution used in operator().
proposerProposer_type object used to initialize internal proposer used in operator().
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
virtual Basic_mh_step< Model, Proposer_type >::~Basic_mh_step ( )
inlinevirtual

Initializes target and proposer functors (or functions) to the given arguments.

Parameters
log_targetTarget_distribution object used to initialize internal target distribution used in operator().
proposerProposer_type object used to initialize internal proposer used in operator().
default_modelIf Model is not default-constructible, you need to provide a model to initialize new models. Copy-constructor

Member Function Documentation

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
Proposer_type& Basic_mh_step< Model, Proposer_type >::get_proposer_ ( )
inlineprotected
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
virtual double Basic_mh_step< Model, Proposer_type >::get_temperature ( ) const
inlinevirtual
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
virtual double Basic_mh_step< Model, Proposer_type >::l_target ( const Model &  m) const
inlinevirtual

Evaluate the log-target distribution for the given model.

Implements Abstract_mh_step< Model, Proposer_type >.

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
virtual Mh_proposal_result Basic_mh_step< Model, Proposer_type >::propose ( const Model &  m,
Model &  m_p 
) const
inlinevirtual

Assignment.

Propose a new model

Implements Abstract_mh_step< Model, Proposer_type >.

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
void Basic_mh_step< Model, Proposer_type >::record_extra ( bool  enable)
inline

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

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
virtual bool Basic_mh_step< Model, Proposer_type >::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 from Abstract_mh_step< Model, Proposer_type >.

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
void Basic_mh_step< Model, Proposer_type >::set_target ( const Target_distribution target)
inline

Set the log-target distribution. Generally it's preferred to set this in the constructor, but this is occasionally useful when implementing copy constructor that needs to copy everything except the target, which you'll set yourself. This comes up when you're doing fancy stuff with the target distribution, like introducing coupling with other objects, and you need to maintain correct references, which the default copy constructor won't let you do.

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
void Basic_mh_step< Model, Proposer_type >::set_temperature ( double  T)
inline

Set annealing temperature. Increases acceptance rate; proposal distribution is unaffected

Member Data Documentation

template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
Target_distribution Basic_mh_step< Model, Proposer_type >::m_log_target
protected
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
Proposer_type Basic_mh_step< Model, Proposer_type >::m_proposer
protected
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
bool Basic_mh_step< Model, Proposer_type >::m_record_extra
protected
template<typename Model, typename Proposer_type = typename Mh_model_proposer<Model>::Type>
double Basic_mh_step< Model, Proposer_type >::m_temperature
protected

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