![]() |
#include <baseHamiltonian.h>
Public Member Functions | |
baseHamiltonian (int dim) | |
double | dim () |
Return the dimensionality of the target space. | |
virtual double | T ()=0 |
Return the kinetic energy. | |
virtual double | V ()=0 |
Return the potential energy. | |
virtual const VectorXd & | gradV ()=0 |
Return the gradient of the potential energy. | |
double | H () |
Return the Hamiltonian. | |
VectorXd & | q () |
Return the current position. | |
double | q (int i) |
Return the ith component of the current position. | |
VectorXd & | p () |
Return the current momentum. | |
double | p (int i) |
Return the ith component of the current momentum. | |
VectorXd & | acceptQ () |
Return the currect accept window sample. | |
VectorXd & | rejectQ () |
Return the currect reject window sample. | |
virtual void | evolveQ (const double epsilon)=0 |
Evolve the position through some time epsilon. | |
virtual void | prepareEvolution () |
virtual void | beginEvolveP (const double epsilon)=0 |
Evolve the momenta through an initial half step of time epsilon. | |
virtual void | finishEvolveP (const double epsilon)=0 |
Evolve the momenta through a final half step of time epsilon. | |
virtual void | bounceP (const VectorXd &normal)=0 |
virtual void | sampleP (Random &random)=0 |
void | saveCurrentPoint () |
Save current position and momentum. | |
void | restoreStoredPoint () |
Restore saved position and momentum. | |
void | saveAsRejectSample () |
Save current position as a sample from the reject window. | |
void | saveAsAcceptSample () |
Save current position as a sample from the accept window. | |
void | sampleWindows (const bool accept) |
Select between the reject and accept windows. | |
void | setAverageDecay (const double alpha) |
Set moving average decay rate. | |
void | updateMetroStats (const bool b, const double a) |
Update Metroplis accept rate statistics. | |
void | clearHistory () |
Clear all convergence diagnostic statistics. | |
bool | isNaN () |
Check if the position of the chain is well defined. | |
virtual bool | supportViolated () |
Is the chain within the support of the distribution? | |
virtual VectorXd & | supportNormal () |
Return the normal to the support boundary. | |
virtual void | checkEvolution (const double epsilon=1e-6) |
Comparing the evolution implementations with finite differences. | |
double | acceptRate () |
Metropolis accept rate over the history of the chains. | |
double | movingAcceptRate () |
Moving expectation of the Metropolis accept rate. | |
virtual void | displayState () |
Display current state. | |
Protected Attributes | |
const int | mDim |
Dimension of target space. | |
VectorXd | mQ |
Position in target space. | |
VectorXd | mStoreQ |
Stored position. | |
VectorXd | mRejectQ |
Stored position in reject window. | |
VectorXd | mAcceptQ |
Stored position in accept window. | |
VectorXd | mP |
Momentum. | |
VectorXd | mStoreP |
Stored momentum. | |
VectorXd | mN |
Normal to any surface of constrained support. | |
VectorXd | mGradV |
Gradient of the potential energy. | |
double | mNumAccept |
Total number of accepted samples. | |
double | mNumReject |
Total number of rejected samples. | |
double | mAcceptRateBar |
Moving average accept rate. | |
double | mEffN |
Moving average effective samples. | |
double | mMovingAlpha |
Moving average decay rate. |
Abstract base class defining the interface for a generic Hamiltonian Monte Carlo chain, with the potential energy given by a target distribution and the kinetic energy left free for optimization.
baseHamiltonian::baseHamiltonian | ( | int | dim | ) | [explicit] |
Constructor
dim | Dimension of the target space |
virtual void baseHamiltonian::bounceP | ( | const VectorXd & | normal | ) | [pure virtual] |
Evolve the momentum through a bounce off of a constraint surface
normal | Vector normal to constraint surface |
Implemented in denseConstMetric, denseFisherMetric, diagConstMetric, diagOuterSoftAbsMetric, diagSoftAbsMetric, outerSoftAbsMetric, and softAbsMetric.
void baseHamiltonian::checkEvolution | ( | const double | epsilon = 1e-6 | ) | [virtual] |
Comparing the evolution implementations with finite differences.
Compare the position and momentum evolution implementations with finite differences
epsilon | Size of finite difference step |
Reimplemented in denseFisherMetric, diagOuterSoftAbsMetric, diagSoftAbsMetric, outerSoftAbsMetric, and softAbsMetric.
virtual void baseHamiltonian::prepareEvolution | ( | ) | [inline, virtual] |
Perform any necessary calculations before simulation Hamiltonian dynamics
Reimplemented in denseFisherMetric, dynamMetric, and outerSoftAbsMetric.
virtual void baseHamiltonian::sampleP | ( | Random & | random | ) | [pure virtual] |
Sample the momentum from a conditional distribution of
random | External RandomLib generator |
Implemented in denseConstMetric, denseFisherMetric, diagConstMetric, diagOuterSoftAbsMetric, diagSoftAbsMetric, outerSoftAbsMetric, and softAbsMetric.