vSMC
vSMC: Scalable Monte Carlo
|
Monitor for Path sampling. More...
#include <vsmc/core/path.hpp>
Public Types | |
using | eval_type = std::function< double(std::size_t, Particle< T > &, double *)> |
using | value_type = T |
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, 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... | |
using vsmc::Path< T >::eval_type = std::function<double(std::size_t, Particle<T> &, double *)> |
using vsmc::Path< T >::value_type = T |
|
inlineexplicit |
Construct a Path with an evaluation object.
eval | The evaluation object of type Path::eval_type |
record_only | The 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
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\).
|
inline |
|
inline |
|
inline |
Perform the evaluation for a given iteration and a Particle<T> object
|
inline |
|
inline |
|
inline |
Get the iteration index of the sampler of a given monitor iteration.
|
inline |
|
inline |
|
inline |
|
inline |
The number of iterations has been recorded.
|
inline |
|
inline |
|
inline |
Read the index history through an output iterator.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |