vSMC
vSMC: Scalable Monte Carlo
Public Types | Public Member Functions | List of all members
vsmc::Path< T > Class Template Reference

Monitor for Path sampling. More...

#include <vsmc/core/path.hpp>

Public Types

typedef cxx11::function< double(std::size_t, const Particle< T > &, double *)> eval_type
 
typedef T value_type
 

Public Member Functions

 Path (const eval_type &eval, bool record_only=false)
 Construct a Path with an evaluation object. More...
 
void clear ()
 Clear all records of the index and integrations. More...
 
bool empty () const
 Whether the evaluation object is valid. More...
 
void eval (std::size_t iter, const Particle< T > &particle)
 
double grid (std::size_t iter) const
 Get the Path sampling grid value of a given Path iteration. More...
 
const std::size_t * grid_data () const
 Read only access to the raw data of the grid vector. More...
 
std::size_t index (std::size_t iter) const
 Get the iteration index of the sampler of a given monitor iteration. More...
 
const std::size_t * index_data () const
 Read only access to the raw data of the index vector. More...
 
double integrand (std::size_t iter) const
 Get the Path sampling integrand of a given Path iteration. More...
 
const std::size_t * integrand_data () const
 Read only access to the raw data of the integrand vector. More...
 
std::size_t iter_size () const
 The number of iterations has been recorded. More...
 
double log_zconst () const
 Get the logarithm nomralizing constants ratio estimates. More...
 
template<typename OutputIter >
void read_grid (OutputIter first) const
 Read the grid history through an output iterator. More...
 
template<typename OutputIter >
void read_index (OutputIter first) const
 Read the index history through an output iterator. More...
 
template<typename OutputIter >
void read_integrand (OutputIter first) const
 Read the integrand history through an output iterator. More...
 
bool recording () const
 Whether the Path is actively recording restuls. More...
 
void reserve (std::size_t num)
 Reserve space for a specified number of iterations. More...
 
void set_eval (const eval_type &new_eval, bool record_only=false)
 Set a new evaluation object of type eval_type. More...
 
void turn_off ()
 Turn off the recording. More...
 
void turn_on ()
 Turn on the recording. More...
 
double zconst () const
 Get the nomralizing constants ratio estimates. More...
 

Detailed Description

template<typename T>
class vsmc::Path< T >

Monitor for Path sampling.

Definition at line 51 of file path.hpp.

Member Typedef Documentation

template<typename T>
typedef cxx11::function<double ( std::size_t, const Particle<T> &, double *)> vsmc::Path< T >::eval_type

Definition at line 57 of file path.hpp.

template<typename T>
typedef T vsmc::Path< T >::value_type

Definition at line 55 of file path.hpp.

Constructor & Destructor Documentation

template<typename T>
vsmc::Path< T >::Path ( const eval_type eval,
bool  record_only = false 
)
inlineexplicit

Construct a Path with an evaluation object.

Parameters
evalThe evaluation object of type Path::eval_type
record_onlyThe Path monitor only records the integrands instead of calculating them itself

A Path object is very similar to a Monitor object. It is a special case for Path sampling Monitor. The dimension of the Monitor is always one. In addition, the evaluation object returns the integration grid of the Path sampling.

The evaluation object has the signature

double eval (std::size_t iter, const Particle<T> &particle, double *integrand)

where the first two arguments are passed in by the Sampler at the end of each iteration. The evaluation occurs after the possible MCMC moves. The output parameter integrand shall contains the results of the Path sampling integrands. The return value shall be the Path sampling integration grid.

If record_only is true, then the Path monitor only records the integrand estimate stored in integrand. Otherwise the behavior is explained below,

For example, say the Path sampling is computed through integration of \(\lambda = \int_0^1 E[g_\alpha(X)]\,\mathrm{d}\alpha\). The integral is approximated with numerical integration at point \(\alpha_0 = 0, \alpha_1, \dots, \alpha_T = 1\), then at iteration \(t\), the output parameter integrand contains \((g_{\alpha_t}(X_0),\dots)\) and the return value is \(\alpha_t\).

Definition at line 90 of file path.hpp.

Member Function Documentation

template<typename T>
void vsmc::Path< T >::clear ( )
inline

Clear all records of the index and integrations.

Definition at line 201 of file path.hpp.

template<typename T>
bool vsmc::Path< T >::empty ( ) const
inline

Whether the evaluation object is valid.

Definition at line 108 of file path.hpp.

template<typename T>
void vsmc::Path< T >::eval ( std::size_t  iter,
const Particle< T > &  particle 
)
inline

Perform the evaluation for a given iteration and a Particle<T> object

See also
Monitor::eval()

Definition at line 170 of file path.hpp.

template<typename T>
double vsmc::Path< T >::grid ( std::size_t  iter) const
inline

Get the Path sampling grid value of a given Path iteration.

Definition at line 130 of file path.hpp.

template<typename T>
const std::size_t* vsmc::Path< T >::grid_data ( ) const
inline

Read only access to the raw data of the grid vector.

Definition at line 144 of file path.hpp.

template<typename T>
std::size_t vsmc::Path< T >::index ( std::size_t  iter) const
inline

Get the iteration index of the sampler of a given monitor iteration.

See also
Monitor::index()

Definition at line 114 of file path.hpp.

template<typename T>
const std::size_t* vsmc::Path< T >::index_data ( ) const
inline

Read only access to the raw data of the index vector.

Definition at line 138 of file path.hpp.

template<typename T>
double vsmc::Path< T >::integrand ( std::size_t  iter) const
inline

Get the Path sampling integrand of a given Path iteration.

Definition at line 122 of file path.hpp.

template<typename T>
const std::size_t* vsmc::Path< T >::integrand_data ( ) const
inline

Read only access to the raw data of the integrand vector.

Definition at line 141 of file path.hpp.

template<typename T>
std::size_t vsmc::Path< T >::iter_size ( ) const
inline

The number of iterations has been recorded.

See also
Monitor::iter_size()

Definition at line 97 of file path.hpp.

template<typename T>
double vsmc::Path< T >::log_zconst ( ) const
inline

Get the logarithm nomralizing constants ratio estimates.

Definition at line 198 of file path.hpp.

template<typename T>
template<typename OutputIter >
void vsmc::Path< T >::read_grid ( OutputIter  first) const
inline

Read the grid history through an output iterator.

Definition at line 160 of file path.hpp.

template<typename T>
template<typename OutputIter >
void vsmc::Path< T >::read_index ( OutputIter  first) const
inline

Read the index history through an output iterator.

See also
Monitor::read_index()

Definition at line 150 of file path.hpp.

template<typename T>
template<typename OutputIter >
void vsmc::Path< T >::read_integrand ( OutputIter  first) const
inline

Read the integrand history through an output iterator.

Definition at line 155 of file path.hpp.

template<typename T>
bool vsmc::Path< T >::recording ( ) const
inline

Whether the Path is actively recording restuls.

Definition at line 210 of file path.hpp.

template<typename T>
void vsmc::Path< T >::reserve ( std::size_t  num)
inline

Reserve space for a specified number of iterations.

Definition at line 100 of file path.hpp.

template<typename T>
void vsmc::Path< T >::set_eval ( const eval_type new_eval,
bool  record_only = false 
)
inline

Set a new evaluation object of type eval_type.

Definition at line 164 of file path.hpp.

template<typename T>
void vsmc::Path< T >::turn_off ( )
inline

Turn off the recording.

Definition at line 216 of file path.hpp.

template<typename T>
void vsmc::Path< T >::turn_on ( )
inline

Turn on the recording.

Definition at line 213 of file path.hpp.

template<typename T>
double vsmc::Path< T >::zconst ( ) const
inline

Get the nomralizing constants ratio estimates.

Definition at line 195 of file path.hpp.