|
|
| MHRandomWalk (StepRealType step_size, CountIntType n_sweep, CountIntType n_therm, CountIntType n_run, MHWalker &mhwalker, MHRWStatsCollector &stats, Rng &rng, LoggerType &logger_) |
| | Simple constructor, initializes the given fields.
|
| |
|
template<typename MHRWParamsType > |
| | MHRandomWalk (MHRWParamsType &&n_rw, MHWalker &mhwalker, MHRWStatsCollector &stats, Rng &rng, LoggerType &logger_) |
| | Simple constructor, initializes the given fields.
|
| |
|
| MHRandomWalk (const MHRandomWalk &other)=delete |
| |
|
MHRWParamsType | mhrwParams () const |
| | The parameters of the random walk.
|
| |
|
StepRealType | stepSize () const |
| | Get the step size of the random walk.
|
| |
|
CountIntType | nSweep () const |
| | Number of iterations in a sweep.
|
| |
|
CountIntType | nTherm () const |
| | Number of thermalizing sweeps.
|
| |
|
CountIntType | nRun () const |
| | Number of live run sweeps.
|
| |
|
bool | hasAcceptanceRatio () const |
| | Query whether we have any statistics about acceptance ratio. This is false, for example, during the thermalizing runs.
|
| |
|
template<typename RatioType = double> |
| RatioType | acceptanceRatio () const |
| | Return the acceptance ratio so far.
|
| |
| const PointType & | getCurrentPoint () const |
| | Access the current state of the random walk. More...
|
| |
| const FnValueType & | getCurrentPointValue () const |
| | Access the current function value of the random walk. More...
|
| |
| void | setCurrentPoint (const PointType &pt) |
| | Force manual state of random walk. More...
|
| |
| void | run () |
| | Run the random walk. (pun intended) More...
|
| |
template<typename Rng_, typename MHWalker_, typename MHRWStatsCollector_, typename LoggerType_, typename CountIntType_ = int>
class Tomographer::MHRandomWalk< Rng_, MHWalker_, MHRWStatsCollector_, LoggerType_, CountIntType_ >
A Metropolis-Hastings Random Walk.
Implements a Metropolis-Hastings random walk. This takes care of accepting or rejecting a new point and taking samples.
This class takes care to update the state of a random walk for it to perform thermalizing sweeps, followed by "live" runs.
The random walk is composed of iterations. There are n_sweep iterations per "sweep". This number should be approximately chosen such that step_size * n_sweep is of order of the size of the state space. (This is in order to better decorrelate the samples.)
Initially, a number n_therm of thermalizing sweeps are performed. No samples are taken during this period, and this is meant for a Metropolis random walk to find its "valley".
After the thermalizing runs, a number of run sweeps are performed, in which a live sample is taken at the last iteration of each sweep.
- Template Parameters
-
| Rng | is a C++ random number generator (for example, std::mt19937) |
| MHWalker | is responsible for dealing with the state space, providing a new proposal point and calculating the function value at different points. See MHWalker Interface. |
| MHRWStatsCollector | takes care of collecting useful data during a random walk. It should be a type implementing a MHRWStatsCollector interface, see MHRWStatsCollector Interface. |
| LoggerType | is a logger type to which log messages can be generated (see Logging and Loggers) |
| CountIntType | is an integer type used to count the number of iterations. You'll want to use int here, unless you really want to pursue exceptionally long random walks. |
Definition at line 281 of file mhrw.h.
template<typename Rng_, typename MHWalker_, typename MHRWStatsCollector_, typename LoggerType_, typename CountIntType_ = int>
Run the random walk. (pun intended)
This will take care of the full random walk. The specified number of thermalizing sweeps will be run, followed by a number of "live" sweeps where one sample is taken per sweep.
Definition at line 560 of file mhrw.h.
template<typename Rng_, typename MHWalker_, typename MHRWStatsCollector_, typename LoggerType_, typename CountIntType_ = int>
Force manual state of random walk.
This may be called to force setting the current state of the random walk to the given point pt.
Definition at line 442 of file mhrw.h.