MCKL
Monte Carlo Kernel Library
Public Types | Public Member Functions | List of all members
mckl::MCMCSampler< T, U > Class Template Reference

MCMC sampler. More...

#include <mckl/algorithm/mcmc.hpp>

Inherits mckl::Sampler< MCMCSampler< T, U > >.

Public Types

using estimator_type = typename Sampler< MCMCSampler< T, U > >::estimator_type
 
using eval_type = typename Sampler< MCMCSampler< T, U > >::eval_type
 
using state_type = T
 
- Public Types inherited from mckl::Sampler< MCMCSampler< T, U > >
using estimator_type = typename SamplerTrait< MCMCSampler< T, U > >::estimator_type
 
using eval_type = typename SamplerTrait< MCMCSampler< T, U > >::eval_type
 

Public Member Functions

template<typename... Args>
 MCMCSampler (Args &&... args)
 
void clear ()
 Clear all history. More...
 
template<typename Estimator >
std::size_t estimator (Estimator &&estimator)
 
estimator_typeestimator (std::size_t k)
 
const estimator_typeestimator (std::size_t k) const
 
void iterate (std::size_t n=1)
 Iterate the sampler. More...
 
template<typename Eval >
std::size_t mutation (Eval &&eval, std::enable_if_t<!std::is_integral< Eval >::value > *=nullptr)
 Add a new evaluation object for the mutation step. More...
 
eval_typemutation (std::size_t k)
 
const eval_typemutation (std::size_t k) const
 
std::size_t num_iter () const
 The number of iterations already performed. More...
 
template<typename OutputIter >
OutputIter read_accept_history (std::size_t i, OutputIter first) const
 Read accept count history given mutation step index. More...
 
template<typename OutputIter >
OutputIter read_accept_history (MatrixLayout layout, OutputIter first) const
 Read all accept count history into a matrix. More...
 
void reserve (std::size_t n)
 Reserve space for a specified number of iterations. More...
 
void reset ()
 Reset the sampler by clear all history, evaluation objects, and estimators. More...
 
state_typestate ()
 Read and write access to the state object. More...
 
const state_typestate () const
 Read only access to the state object. More...
 
- Public Member Functions inherited from mckl::Sampler< MCMCSampler< T, U > >
void clear ()
 Clear all estimator histories. More...
 
std::basic_ostream< CharT, Traits > & print (std::basic_ostream< CharT, Traits > &os, char sepchar=' ') const
 Print the summary matrix in textual form. More...
 
void reserve (std::size_t n)
 Reserve space for additional iterations. More...
 
void reset ()
 Remove all evaluation and estimation methods. More...
 
Matrix< T, Layout > summary () const
 Return a combined matrix of all estimates. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mckl::Sampler< MCMCSampler< T, U > >
 Sampler (std::size_t steps)
 
Vector< estimator_type > & estimator (std::size_t step)
 
const Vector< estimator_type > & estimator (std::size_t step) const
 
std::size_t estimator (std::size_t step, Estimator &&estimator, std::enable_if_t<!std::is_integral< Estimator >::value > *=nullptr)
 
estimator_typeestimator (std::size_t step, std::size_t k)
 
const estimator_typeestimator (std::size_t step, std::size_t k) const
 
Vector< eval_type > & eval (std::size_t step)
 
const Vector< eval_type > & eval (std::size_t step) const
 
std::size_t eval (std::size_t step, Eval &&eval, std::enable_if_t<!std::is_integral< Eval >::value > *=nullptr)
 
eval_typeeval (std::size_t step, std::size_t k)
 
const eval_typeeval (std::size_t step, std::size_t k) const
 

Detailed Description

template<typename T, typename U>
class mckl::MCMCSampler< T, U >

MCMC sampler.

Definition at line 58 of file mcmc.hpp.

Member Typedef Documentation

◆ estimator_type

template<typename T , typename U >
using mckl::MCMCSampler< T, U >::estimator_type = typename Sampler<MCMCSampler<T, U> >::estimator_type

Definition at line 76 of file mcmc.hpp.

◆ eval_type

template<typename T , typename U >
using mckl::MCMCSampler< T, U >::eval_type = typename Sampler<MCMCSampler<T, U> >::eval_type

Definition at line 75 of file mcmc.hpp.

◆ state_type

template<typename T , typename U >
using mckl::MCMCSampler< T, U >::state_type = T

Definition at line 74 of file mcmc.hpp.

Constructor & Destructor Documentation

◆ MCMCSampler()

template<typename T , typename U >
template<typename... Args>
mckl::MCMCSampler< T, U >::MCMCSampler ( Args &&...  args)
inlineexplicit

Definition at line 79 of file mcmc.hpp.

Member Function Documentation

◆ clear()

template<typename T , typename U >
void mckl::MCMCSampler< T, U >::clear ( )
inline

Clear all history.

Definition at line 111 of file mcmc.hpp.

◆ estimator() [1/3]

template<typename T , typename U >
template<typename Estimator >
std::size_t mckl::MCMCSampler< T, U >::estimator ( Estimator &&  estimator)
inline

Definition at line 131 of file mcmc.hpp.

◆ estimator() [2/3]

template<typename T , typename U >
estimator_type& mckl::MCMCSampler< T, U >::estimator ( std::size_t  k)
inline

Definition at line 137 of file mcmc.hpp.

◆ estimator() [3/3]

template<typename T , typename U >
const estimator_type& mckl::MCMCSampler< T, U >::estimator ( std::size_t  k) const
inline

Definition at line 142 of file mcmc.hpp.

◆ iterate()

template<typename T , typename U >
void mckl::MCMCSampler< T, U >::iterate ( std::size_t  n = 1)
inline

Iterate the sampler.

Definition at line 148 of file mcmc.hpp.

◆ mutation() [1/3]

template<typename T , typename U >
template<typename Eval >
std::size_t mckl::MCMCSampler< T, U >::mutation ( Eval &&  eval,
std::enable_if_t<!std::is_integral< Eval >::value > *  = nullptr 
)
inline

Add a new evaluation object for the mutation step.

Definition at line 120 of file mcmc.hpp.

◆ mutation() [2/3]

template<typename T , typename U >
eval_type& mckl::MCMCSampler< T, U >::mutation ( std::size_t  k)
inline

Definition at line 126 of file mcmc.hpp.

◆ mutation() [3/3]

template<typename T , typename U >
const eval_type& mckl::MCMCSampler< T, U >::mutation ( std::size_t  k) const
inline

Definition at line 128 of file mcmc.hpp.

◆ num_iter()

template<typename T , typename U >
std::size_t mckl::MCMCSampler< T, U >::num_iter ( ) const
inline

The number of iterations already performed.

Definition at line 87 of file mcmc.hpp.

◆ read_accept_history() [1/2]

template<typename T , typename U >
template<typename OutputIter >
OutputIter mckl::MCMCSampler< T, U >::read_accept_history ( std::size_t  i,
OutputIter  first 
) const
inline

Read accept count history given mutation step index.

Definition at line 166 of file mcmc.hpp.

◆ read_accept_history() [2/2]

template<typename T , typename U >
template<typename OutputIter >
OutputIter mckl::MCMCSampler< T, U >::read_accept_history ( MatrixLayout  layout,
OutputIter  first 
) const
inline

Read all accept count history into a matrix.

Definition at line 177 of file mcmc.hpp.

◆ reserve()

template<typename T , typename U >
void mckl::MCMCSampler< T, U >::reserve ( std::size_t  n)
inline

Reserve space for a specified number of iterations.

Definition at line 94 of file mcmc.hpp.

◆ reset()

template<typename T , typename U >
void mckl::MCMCSampler< T, U >::reset ( )
inline

Reset the sampler by clear all history, evaluation objects, and estimators.

Definition at line 104 of file mcmc.hpp.

◆ state() [1/2]

template<typename T , typename U >
state_type& mckl::MCMCSampler< T, U >::state ( )
inline

Read and write access to the state object.

Definition at line 159 of file mcmc.hpp.

◆ state() [2/2]

template<typename T , typename U >
const state_type& mckl::MCMCSampler< T, U >::state ( ) const
inline

Read only access to the state object.

Definition at line 162 of file mcmc.hpp.