Defines an MCMC sampler with a single chain. More...
#include <SingleChainMCMC.h>
Defines an MCMC sampler with a single chain.
Configuration Parameters:
Parameter Key | Type | Default Value | Description |
---|---|---|---|
"NumSamples" | Int | - | The total number of steps (including burnin) to take, i.e., the length of the Markov chain. |
"BurnIn" | Int | 0 | The number of steps at the beginning of the chain to ignore. |
"PrintLevel" | Int | 3 | The amount of information to print to std::cout. Valid values are in [0,1,2,3] with 0 = Nothing, 3 = The most |
"KernelList" | String | - | A comma separated list of other parameter blocks that define the transition kernels for each Metropolis-in-Gibbs block. |
Definition at line 28 of file SingleChainMCMC.h.
Public Member Functions | |
SingleChainMCMC (boost::property_tree::ptree pt, std::shared_ptr< parcer::Communicator > const &comm, std::vector< std::shared_ptr< TransitionKernel > > const &kernelsIn) | |
SingleChainMCMC (boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > const &problem, std::shared_ptr< parcer::Communicator > const &comm) | |
SingleChainMCMC (boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > const &problem) | |
SingleChainMCMC (boost::property_tree::ptree pt, std::vector< std::shared_ptr< TransitionKernel > > const &kernels) | |
SingleChainMCMC (boost::property_tree::ptree pt, std::shared_ptr< TransitionKernel > const &kernel) | |
virtual | ~SingleChainMCMC ()=default |
virtual void | SetState (std::shared_ptr< SamplingState > const &x0) |
Set the state of the MCMC chain. More... | |
virtual void | SetState (std::vector< Eigen::VectorXd > const &x0) |
template<typename... Args> | |
void | SetState (Args const &... args) |
virtual std::vector< std::shared_ptr< TransitionKernel > > & | Kernels () |
template<typename... Args> | |
std::shared_ptr< MarkovChain > | Run (Args const &... args) |
virtual std::shared_ptr< MarkovChain > | Run (std::vector< Eigen::VectorXd > const &x0) |
virtual double | TotalTime () |
virtual void | AddNumSamps (unsigned int numNewSamps) |
virtual unsigned int | NumSamps () const |
void | PrintStatus (std::string prefix) const |
virtual std::shared_ptr< MarkovChain > | GetSamples () const |
std::shared_ptr< MarkovChain > | GetQOIs () const |
std::shared_ptr< parcer::Communicator > | GetCommunicator () const |
muq::SamplingAlgorithms::SingleChainMCMC::SingleChainMCMC | ( | boost::property_tree::ptree | pt, |
std::shared_ptr< parcer::Communicator > const & | comm, | ||
std::vector< std::shared_ptr< TransitionKernel > > const & | kernelsIn | ||
) |
muq::SamplingAlgorithms::SingleChainMCMC::SingleChainMCMC | ( | boost::property_tree::ptree | pt, |
std::shared_ptr< AbstractSamplingProblem > const & | problem, | ||
std::shared_ptr< parcer::Communicator > const & | comm | ||
) |
muq::SamplingAlgorithms::SingleChainMCMC::SingleChainMCMC | ( | boost::property_tree::ptree | pt, |
std::shared_ptr< AbstractSamplingProblem > const & | problem | ||
) |
SingleChainMCMC::SingleChainMCMC | ( | boost::property_tree::ptree | pt, |
std::vector< std::shared_ptr< TransitionKernel > > const & | kernels | ||
) |
Definition at line 23 of file SingleChainMCMC.cpp.
References Setup().
|
inline |
Definition at line 49 of file SingleChainMCMC.h.
|
virtualdefault |
|
inlinevirtual |
When the Run method is called, the Sample() method is called until the total number of samples generated by this class is equal to a private member variable numSamps
. numSamps
is generally set in the options passed to the constructor. In order to generate more samples after an initial call to Run
, the numSamps variables needs to be increasd. This function essentially sets numSamps=numSamps+numNewSamps.
Typical usage will be something like:
[in] | numNewSamps | The number of new samples we want to add to numSamps. After calling this function, the next call to Run will add an additional numNewSamps to the SampleCollection. |
Definition at line 103 of file SingleChainMCMC.h.
References numSamps.
std::shared_ptr<parcer::Communicator> muq::SamplingAlgorithms::SingleChainMCMC::GetCommunicator | ( | ) | const |
std::shared_ptr< MarkovChain > SingleChainMCMC::GetQOIs | ( | ) | const |
Returns the Quantities of Interest (if any) computed so far.
Definition at line 229 of file SingleChainMCMC.cpp.
References QOIs.
|
virtual |
Returns the samples generated by the algorithm so far.
Definition at line 227 of file SingleChainMCMC.cpp.
References samples.
|
inlinevirtual |
Definition at line 68 of file SingleChainMCMC.h.
References kernels.
|
inlinevirtual |
Returns the current value of the private numSamps variable. When Run
is called, it calls the Sample
function until this number of samples has been generated. Note that unless numSamps is updated by calling AddNumSamps, subsequent calls to Run will produce any new samples.
Definition at line 110 of file SingleChainMCMC.h.
References numSamps.
void SingleChainMCMC::PrintStatus | ( | std::string | prefix | ) | const |
|
protected |
Definition at line 109 of file SingleChainMCMC.cpp.
References kernels, numSamps, and printLevel.
|
inlineprotected |
Definition at line 134 of file SingleChainMCMC.h.
References PrintStatus().
Referenced by PrintStatus().
|
inline |
Definition at line 71 of file SingleChainMCMC.h.
References RunRecurse().
Referenced by RunRecurse().
|
virtual |
Definition at line 120 of file SingleChainMCMC.cpp.
References numSamps, printLevel, PrintStatus(), Sample(), samples, sampNum, SetState(), and totalTime.
|
inlineprivate |
Definition at line 168 of file SingleChainMCMC.h.
References Run().
|
inlineprivate |
Definition at line 158 of file SingleChainMCMC.h.
Referenced by Run().
|
inlineprivate |
Definition at line 163 of file SingleChainMCMC.h.
References nlohmann::detail::last, and Run().
|
protectedvirtual |
Definition at line 153 of file SingleChainMCMC.cpp.
References kernels, lastSavedState, prevState, sampNum, SaveSamples(), and totalTime.
Referenced by Run().
|
protected |
Definition at line 194 of file SingleChainMCMC.cpp.
References numSamps, QOIs, samples, sampNum, and ShouldSave().
Referenced by Sample().
|
inline |
Definition at line 63 of file SingleChainMCMC.h.
References SetStateRecurse().
|
virtual |
Set the state of the MCMC chain.
If no steps have been taken, this function sets the starting point. Set the current state AND adds it to the sample collection.
Definition at line 220 of file SingleChainMCMC.cpp.
References prevState, samples, and ShouldSave().
Referenced by Run(), SetState(), and SetStateRecurse().
|
virtual |
Definition at line 216 of file SingleChainMCMC.cpp.
References SetState().
|
inlineprivate |
Definition at line 173 of file SingleChainMCMC.h.
Referenced by SetState().
|
inlineprivate |
Definition at line 178 of file SingleChainMCMC.h.
References nlohmann::detail::last, and SetState().
|
private |
|
private |
Referenced by SingleChainMCMC().
|
protected |
Definition at line 214 of file SingleChainMCMC.cpp.
References burnIn, sampNum, and scheduler.
Referenced by SaveSamples(), and SetState().
|
inlinevirtual |
Definition at line 78 of file SingleChainMCMC.h.
References totalTime.
|
protected |
Definition at line 145 of file SingleChainMCMC.h.
Referenced by ShouldSave().
|
private |
Definition at line 154 of file SingleChainMCMC.h.
|
protected |
Definition at line 149 of file SingleChainMCMC.h.
Referenced by Kernels(), PrintStatus(), and Sample().
|
private |
Definition at line 185 of file SingleChainMCMC.h.
Referenced by Sample().
|
protected |
Definition at line 144 of file SingleChainMCMC.h.
Referenced by AddNumSamps(), NumSamps(), PrintStatus(), Run(), and SaveSamples().
|
private |
Definition at line 184 of file SingleChainMCMC.h.
Referenced by Sample(), and SetState().
|
protected |
Definition at line 146 of file SingleChainMCMC.h.
Referenced by PrintStatus(), and Run().
|
protected |
Definition at line 139 of file SingleChainMCMC.h.
Referenced by GetQOIs(), and SaveSamples().
|
protected |
Definition at line 138 of file SingleChainMCMC.h.
Referenced by GetSamples(), Run(), SaveSamples(), and SetState().
|
private |
Definition at line 183 of file SingleChainMCMC.h.
Referenced by Run(), Sample(), SaveSamples(), and ShouldSave().
|
protected |
Definition at line 141 of file SingleChainMCMC.h.
Referenced by ShouldSave().
|
protected |
Definition at line 142 of file SingleChainMCMC.h.
|
private |
Definition at line 186 of file SingleChainMCMC.h.
Referenced by Run(), Sample(), and TotalTime().