vSMC
vSMC: Scalable Monte Carlo
Public Types | Public Member Functions | List of all members
vsmc::RandomWalkG< RealType, DimX, DimG > Class Template Reference

Random walk MCMC update with test function. More...

#include <vsmc/rng/internal/common.hpp>

Public Types

using result_type = RealType
 

Public Member Functions

 RandomWalkG ()
 Only usable when DimX != Dynamic and DimG != Dynamic More...
 
 RandomWalkG (std::size_t dim_x, std::size_t dim_g)
 Only usable when DimX == Dynamic and DimG == Dynamic More...
 
std::size_t dim_g () const
 
std::size_t dim_x () const
 
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t operator() (RNGType &rng, result_type *x, result_type *ltx, result_type *g, LogTargetType &&log_target, ProposalType &&proposal)
 One-step random walk update. More...
 
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t operator() (RNGType &rng, std::size_t m, std::size_t idx, result_type *x, result_type *ltx, result_type *g, LogTargetType &&log_target, ProposalType &&proposal)
 One-step random walk update of a block of elements within a vector state. More...
 
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t operator() (std::size_t n, RNGType &rng, result_type *x, result_type *ltx, result_type *g, LogTargetType &&log_target, ProposalType &&proposal)
 Multi-step random walk update. More...
 
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t operator() (std::size_t n, RNGType &rng, std::size_t m, std::size_t idx, result_type *x, result_type *ltx, result_type *g, LogTargetType &&log_target, ProposalType &&proposal)
 Multi-step random walk update of a block of element within a vector state. More...
 

Detailed Description

template<typename RealType, std::size_t DimX, std::size_t DimG>
class vsmc::RandomWalkG< RealType, DimX, DimG >

Random walk MCMC update with test function.

Definition at line 537 of file common.hpp.

Member Typedef Documentation

template<typename RealType , std::size_t DimX, std::size_t DimG>
using vsmc::RandomWalkG< RealType, DimX, DimG >::result_type = RealType

Definition at line 199 of file random_walk.hpp.

Constructor & Destructor Documentation

template<typename RealType , std::size_t DimX, std::size_t DimG>
vsmc::RandomWalkG< RealType, DimX, DimG >::RandomWalkG ( )
inline

Only usable when DimX != Dynamic and DimG != Dynamic

Definition at line 202 of file random_walk.hpp.

template<typename RealType , std::size_t DimX, std::size_t DimG>
vsmc::RandomWalkG< RealType, DimX, DimG >::RandomWalkG ( std::size_t  dim_x,
std::size_t  dim_g 
)
inline

Only usable when DimX == Dynamic and DimG == Dynamic

Definition at line 209 of file random_walk.hpp.

Member Function Documentation

template<typename RealType , std::size_t DimX, std::size_t DimG>
std::size_t vsmc::RandomWalkG< RealType, DimX, DimG >::dim_g ( ) const
inline

Definition at line 217 of file random_walk.hpp.

template<typename RealType , std::size_t DimX, std::size_t DimG>
std::size_t vsmc::RandomWalkG< RealType, DimX, DimG >::dim_x ( ) const
inline

Definition at line 216 of file random_walk.hpp.

template<typename RealType , std::size_t DimX, std::size_t DimG>
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t vsmc::RandomWalkG< RealType, DimX, DimG >::operator() ( RNGType &  rng,
result_type x,
result_type ltx,
result_type g,
LogTargetType &&  log_target,
ProposalType &&  proposal 
)
inline

One-step random walk update.

Parameters
rngRNG engine
xThe current state value. It will be updated to the new value after the MCMC move.
ltxIf it is a non-null pointer, then it points to the value of the \(\log\gamma(x)\). It will be updated to the new value if the MCMC move is accepted and left unchanged otherwise. If it is a null pointer, then it is ignored. Use this pointer to save \(\log\gamma(x)\) between updates if it is expensive to calculate.
gIf it is a non-null pointer, then it is used to save the value of the test function \(g(x)\) if the MCMC move is accepted and left unchanged otherwise. If it is a null pointer, then it is ignored.
log_targetThe log-target fucntion
result_type log_target(std::size_t dim_x, std::size_t dim_g,
const result_type *x, result_type *g);
It accepts the lengths of the state vector and test function value vector, and pointers to the storage of the state value and test function value. It return the value of log-target function \(\log\gamma(x)\). Note that this fucntion shall be able to handle its argument g as a null pointer.
proposalThe proposal function. It takes the form,
result_type proposal(RNGType &rng, std::size_t dim,
const result_type *x, result_type *y);
After the call, the function return the proposed value in y and return the value \(\log(q(y, x) / q(x, y))\).
Returns
Acceptance count

Definition at line 252 of file random_walk.hpp.

template<typename RealType , std::size_t DimX, std::size_t DimG>
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t vsmc::RandomWalkG< RealType, DimX, DimG >::operator() ( RNGType &  rng,
std::size_t  m,
std::size_t  idx,
result_type x,
result_type ltx,
result_type g,
LogTargetType &&  log_target,
ProposalType &&  proposal 
)
inline

One-step random walk update of a block of elements within a vector state.

With this operator, it is assumed that the length of input/output state vector x is of length m instead of dim_x(). A sub-vector of length dim_x(), starting at index idx will be updated. The log-target function will be called with m as its first argument and a length m vector will be passed as its third argument as well.

Definition at line 285 of file random_walk.hpp.

template<typename RealType , std::size_t DimX, std::size_t DimG>
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t vsmc::RandomWalkG< RealType, DimX, DimG >::operator() ( std::size_t  n,
RNGType &  rng,
result_type x,
result_type ltx,
result_type g,
LogTargetType &&  log_target,
ProposalType &&  proposal 
)
inline

Multi-step random walk update.

Definition at line 314 of file random_walk.hpp.

template<typename RealType , std::size_t DimX, std::size_t DimG>
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t vsmc::RandomWalkG< RealType, DimX, DimG >::operator() ( std::size_t  n,
RNGType &  rng,
std::size_t  m,
std::size_t  idx,
result_type x,
result_type ltx,
result_type g,
LogTargetType &&  log_target,
ProposalType &&  proposal 
)
inline

Multi-step random walk update of a block of element within a vector state.

Definition at line 335 of file random_walk.hpp.