|
|
| MHRandomWalk (MHWalkerParams mhwalker_params, CountIntType n_sweep, CountIntType n_therm, CountIntType n_run, MHWalker &mhwalker, MHRWStatsCollector &stats, MHRWController &mhrw_controller, Rng &rng, LoggerType &logger_) |
| | Simple constructor, initializes the given fields.
|
| |
|
template<typename MHRWParamsTypeInit > |
| | MHRandomWalk (MHRWParamsTypeInit &&n_rw, MHWalker &mhwalker, MHRWStatsCollector &stats, MHRWController &mhrw_controller, Rng &rng, LoggerType &logger_) |
| | Simple constructor, initializes the given fields.
|
| |
|
| MHRandomWalk (const MHRandomWalk &other)=delete |
| |
|
const MHRWStatsCollector & | statsCollector () const |
| | Access the stats collector.
|
| |
|
const MHRWController & | mhrwController () const |
| | Access the random walk controller.
|
| |
|
MHRWParamsType | mhrwParams () const |
| | The parameters of the random walk.
|
| |
|
MHWalkerParams | mhWalkerParams () const |
| | Get the MHWalker parameters.
|
| |
|
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 MHRWController_ = MHRWNoController, typename LoggerType_ = Logger::VacuumLogger, typename CountIntType_ = int>
class Tomographer::MHRandomWalk< Rng_, MHWalker_, MHRWStatsCollector_, MHRWController_, 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.
- Since
- Since Tomographer 5.0: added MHRWController.
- 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. |
| MHRWController | a MHRWController Interface compliant type which may dynamically adjust the parameters of the random walker. Just specify MHRWNoController if you don't need the parameters to be dynamically adjusted. |
| 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 643 of file mhrw.h.
template<typename Rng_ , typename MHWalker_ , typename MHRWStatsCollector_ , typename MHRWController_ = MHRWNoController, typename LoggerType_ = Logger::VacuumLogger, typename CountIntType_ = int>
Access the current state of the random walk.
- Returns
- the current point the random walk is located at.
Definition at line 806 of file mhrw.h.
template<typename Rng_ , typename MHWalker_ , typename MHRWStatsCollector_ , typename MHRWController_ = MHRWNoController, typename LoggerType_ = Logger::VacuumLogger, typename CountIntType_ = int>
Access the current function value of the random walk.
- Returns
- the current value of the function in the current state of the random walk.
- Warning
- the meaning of this value depends on
MHRandomWalk::UseFnSyntaxType. It is either the value of the function, its logarithm, or a dummy value.
Definition at line 818 of file mhrw.h.
template<typename Rng_ , typename MHWalker_ , typename MHRWStatsCollector_ , typename MHRWController_ = MHRWNoController, typename LoggerType_ = Logger::VacuumLogger, 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 1053 of file mhrw.h.
template<typename Rng_ , typename MHWalker_ , typename MHRWStatsCollector_ , typename MHRWController_ = MHRWNoController, typename LoggerType_ = Logger::VacuumLogger, 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 828 of file mhrw.h.