Conditional Sampler
Defines the conditionalSampler class derived from base sampler.
This file defines the smc::conditionalSampler class which is used to implement entire particle systems for conditional sequential Monte Carlo. The class is derived from the base class ‘sampler’ but currently does not implement facilities of the base class that are not striclty required for conditional SMC (such as MCMC moves or adaptation). Conditional resampling for (some) common resampling mechanisms are implemented.
Defines
-
__SMC_CONDITIONAL_SAMPLER_HH
-
namespace smc
The Sequential Monte Carlo namespace.
The classes and functions within this namespace are intended to be used for producing implemenetations of SMC samplers and related simulation techniques.
Functions
-
template<class Space, class Params>
std::ostream &operator<<(std::ostream&, const conditionalSampler<Space, Params>&) Produce a human-readable display of the state of an smc::sampler class using the stream operator.
- Parameters
os – The output stream to which the display should be made.
s – The sampler which is to be displayed.
-
template<class Space, class Params = nullParams>
class conditionalSampler : public smc::sampler<Space, nullParams> - #include <conditionalSampler.h>
Public Functions
-
inline conditionalSampler(long lSize, HistoryType::Enum htHistoryMode, std::vector<Space> referenceTrajectoryInit)
Create an particle system containing lSize uninitialised particles with the specified mode.
-
inline conditionalSampler(long lSize, HistoryType::Enum htHistoryMode, moveset<Space, Params> *pNewMoves, std::vector<Space> referenceTrajectoryInit)
Create an particle system containing lSize uninitialised particles with the specified mode, additionally passing a moveset-object.
-
inline int GetDigitsPrint(void) const
Get the number of digits used in ostream<< operator printing.
-
inline void SetDigitsPrint(int newDigitsPrint)
Set the number of digits used in ostream<< operator printing.
-
inline const std::vector<Space> &GetReferenceTrajectoryRefs(void) const
Returns a constant reference to the reference trajectory.
-
inline const Space &GetReferenceValueRefs(long n) const
Returns a constant reference to the n’th element of the reference trajectory.
-
inline const long GetReferenceValueIndex(long lTime) const
Returns index of conditional reference Trajectory.
-
inline void SetReferenceTrajectory(const std::vector<Space> &newReferenceTrajectory)
Sets the reference trajectory.
-
inline void SetReferenceValue(const Space &newReferenceValue, long n)
Sets the n’elment of the reference trajectory.
-
void Initialise(void)
Initialise the conditional sampler and its constituent particles. The reference trajectory used to set the first coordinate at T=0 is either from the last call to conditionalSampler.SetReferenceTrajectory(), or defaults to the trajectory passed to the constructor at the time the object is created.
At present this function resets the system evolution time to 0 and calls the moveset initialisor to assign each particle in the ensemble.
Note that the initialisation function must be specified before calling this function.
Additionally, the t=0 particle coordinate is set to the conditional reference value and re-weighted.
-
void Initialise(const std::vector<Space> &newReferenceTrajectory)
Initialise the sampler and its constituent particles.
At present this function resets the system evolution time to 0 and calls the moveset initialisor to assign each particle in the ensemble.
Note that the initialisation function must be specified before calling this function.
Additionally, a conditional particle trajectory is set and the t=0 particle coordinate is set to the conditional reference value and re-weighted.
-
void Iterate(void)
Perform one conditional iteration of the simulation algorithm.
-
double IterateEss(void)
Perform one conditional iteration of the simulation algorithm and return the resulting ess.
-
void IterateUntil(long lTerminate)
Perform conditional iterations until the specified evolution time is reached.
-
void conditionalResample(ResampleType::Enum lMode)
Resample the particle set using the specified resampling scheme specifically adjusted for conditional resampling.
-
void MoveReferenceParticle(void)
Move the reference particle by setting the coordinate to the reference value and re-weighting.
-
std::ostream &StreamParticle(std::ostream &os, long n) const
Dump a specified particle to the specified output stream in a human readable form.
Produce a human-readable display of the current n’th particle value and log weight.
- Parameters
os – The output stream to which the display should be made.
n – The index of the particle of interest
-
std::ostream &StreamParticles(std::ostream &os, int digits) const
Dump the entire particle set to the specified output stream in a human readable form.
Produce a human-readable display of the current particle values and log weights.
- Parameters
os – The output stream to which the display should be made.
-
inline void SetAdaptMethods(adaptMethods<Space, Params> *adaptMethod)
Throws exception when adaptation related members of the base sampler class are used:
-
inline void SetMcmcRepeats(adaptMethods<Space, Params> *adaptMethod)
Throws exception when members related to MCMC moves of the base sampler class are used:
-
inline int GetAccepted(void) const
-
inline int GetMcmcRepeats(void) const
-
inline int GetHistorymcmcRepeats(long n)
-
inline void SetMcmcRepeats(int reps)
Sets the number of MCMC repeats.
Private Members
-
long maxT = referenceTrajectory.size()
-
arma::Col<unsigned int> referenceTrajectoryIndices
-
int digitsPrint = 6
Friends
-
friend std::ostream &operator<<(std::ostream&, const conditionalSampler<Space, Params>&)
Produce a human-readable display of the state of an smc::sampler class using the stream operator.
- Parameters
os – The output stream to which the display should be made.
s – The sampler which is to be displayed.
-
inline conditionalSampler(long lSize, HistoryType::Enum htHistoryMode, std::vector<Space> referenceTrajectoryInit)
-
template<class Space, class Params>