vSMC  v3.0.0
Scalable Monte Carlo
Public Types | Public Member Functions | List of all members
vsmc::RandomWalk< RealType, Dim > Class Template Reference

Random walk MCMC update. More...

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

Public Types

using result_type = RealType
 

Public Member Functions

 RandomWalk ()
 Only usable when Dim != Dynamic More...
 
 RandomWalk (std::size_t dim)
 Only usable when Dim == Dynamic More...
 
std::size_t dim () const
 
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t operator() (RNGType &rng, result_type *x, result_type *ltx, 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, 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, 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, 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 Dim>
class vsmc::RandomWalk< RealType, Dim >

Random walk MCMC update.

Definition at line 1053 of file rng/internal/common.hpp.

Member Typedef Documentation

template<typename RealType , std::size_t Dim>
using vsmc::RandomWalk< RealType, Dim >::result_type = RealType

Definition at line 53 of file random_walk.hpp.

Constructor & Destructor Documentation

template<typename RealType , std::size_t Dim>
vsmc::RandomWalk< RealType, Dim >::RandomWalk ( )
inline

Only usable when Dim != Dynamic

Definition at line 56 of file random_walk.hpp.

template<typename RealType , std::size_t Dim>
vsmc::RandomWalk< RealType, Dim >::RandomWalk ( std::size_t  dim)
inline

Only usable when Dim == Dynamic

Definition at line 63 of file random_walk.hpp.

Member Function Documentation

template<typename RealType , std::size_t Dim>
std::size_t vsmc::RandomWalk< RealType, Dim >::dim ( ) const
inline

Definition at line 69 of file random_walk.hpp.

template<typename RealType , std::size_t Dim>
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t vsmc::RandomWalk< RealType, Dim >::operator() ( RNGType &  rng,
result_type x,
result_type ltx,
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.
log_targetThe log-target fucntion
result_type log_target(std::size_t dim_x, const result_type *x );
It accepts the lengths of the state vector and a pointer to the storage of the state value. It return the value of log-target function \(\log\gamma(x)\).
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 98 of file random_walk.hpp.

template<typename RealType , std::size_t Dim>
template<typename RNGType , typename LogTargetType , typename ProposalType >
std::size_t vsmc::RandomWalk< RealType, Dim >::operator() ( RNGType &  rng,
std::size_t  m,
std::size_t  idx,
result_type x,
result_type ltx,
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 second argument as well.

Definition at line 127 of file random_walk.hpp.

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

Multi-step random walk update.

Definition at line 152 of file random_walk.hpp.

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

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

Definition at line 171 of file random_walk.hpp.