Public Member Functions | Protected Attributes
baseHamiltonian Class Reference

#include <baseHamiltonian.h>

Inheritance diagram for baseHamiltonian:
constMetric dynamMetric denseConstMetric diagConstMetric denseFisherMetric diagOuterSoftAbsMetric diagSoftAbsMetric outerSoftAbsMetric softAbsMetric flatFunnel fisherBayesLogReg softAbsBayesLogReg softAbsFunnel

List of all members.

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.

Detailed Description

Author:
Michael Betancourt

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.


Constructor & Destructor Documentation

baseHamiltonian::baseHamiltonian ( int  dim) [explicit]

Constructor

Parameters:
dimDimension of the target space

Member Function Documentation

virtual void baseHamiltonian::bounceP ( const VectorXd &  normal) [pure virtual]

Evolve the momentum through a bounce off of a constraint surface

Parameters:
normalVector 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

Parameters:
epsilonSize 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.

Examples:
examples/main.cpp.
virtual void baseHamiltonian::sampleP ( Random &  random) [pure virtual]

Sample the momentum from a conditional distribution of $ \pi \left( \mathbf{p}, \mathbf{q} \right) \propto \exp \left( - H \right) $

Parameters:
randomExternal RandomLib generator

Implemented in denseConstMetric, denseFisherMetric, diagConstMetric, diagOuterSoftAbsMetric, diagSoftAbsMetric, outerSoftAbsMetric, and softAbsMetric.


The documentation for this class was generated from the following files:
 All Classes Functions Variables