MUQ  0.4.3
muq::SamplingAlgorithms::AMProposal Class Reference

An implemental of the Adaptive Metropolis algorithm. More...

#include <AMProposal.h>

Inheritance diagram for muq::SamplingAlgorithms::AMProposal:

Detailed Description

An implemental of the Adaptive Metropolis algorithm.

Configuration Parameters:

Parameter Key Type Default Value Description
"ProposalVariance" Double 1.0 Initial proposal variance before adaptation begins.
"AdaptSteps" Integer - How often the proposal covariance should be updated.
"AdaptStart" Integer - How many steps should be taken before beginning to adapt the covariance.
"AdaptScale" Double - Scaling of the sample covariance used to define the proposal covariance: \(\Sigma_{prop} = \alpha \hat{\Sigma}\)

Definition at line 21 of file AMProposal.h.

Public Member Functions

 AMProposal (boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > const &prob)
 
 AMProposal (boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > const &prob, Eigen::MatrixXd const &initialCov)
 
virtual ~AMProposal ()=default
 
virtual void Adapt (unsigned int const t, std::vector< std::shared_ptr< SamplingState >> const &states) override
 Adapt the proposal after each step. More...
 
virtual Eigen::MatrixXd ProposalCovariance () const
 
- Public Member Functions inherited from muq::SamplingAlgorithms::MCMCProposal
 MCMCProposal (boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > const &probIn)
 
virtual ~MCMCProposal ()=default
 
void SetCommunicator (std::shared_ptr< parcer::Communicator > newcomm)
 
virtual void SetBlockInd (int newBlockInd)
 
virtual int GetBlockInd () const
 

Additional Inherited Members

- Public Types inherited from muq::SamplingAlgorithms::MCMCProposal
typedef std::function< std::shared_ptr< MCMCProposal >boost::property_tree::ptree, std::shared_ptr< AbstractSamplingProblem >)> MCMCProposalConstructor
 
typedef std::map< std::string, MCMCProposalConstructorMCMCProposalMap
 
- Static Public Member Functions inherited from muq::SamplingAlgorithms::MCMCProposal
static std::shared_ptr< MCMCProposalConstruct (boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > const &probIn)
 Static constructor for the transition kernel. More...
 
static std::shared_ptr< MCMCProposalMapGetMCMCProposalMap ()
 

Constructor & Destructor Documentation

◆ AMProposal() [1/2]

muq::SamplingAlgorithms::AMProposal::AMProposal ( boost::property_tree::ptree  pt,
std::shared_ptr< AbstractSamplingProblem > const &  prob 
)

◆ AMProposal() [2/2]

muq::SamplingAlgorithms::AMProposal::AMProposal ( boost::property_tree::ptree  pt,
std::shared_ptr< AbstractSamplingProblem > const &  prob,
Eigen::MatrixXd const &  initialCov 
)

Construct the adaptive Metropolis proposal with a specific estimate of the target covariance matrix. Note that initailCov will be scaled by the adaptScale parameter set in the ptree and should therefore be an estiamte of the target covariance, not a specification of the proposal covariance.

◆ ~AMProposal()

virtual muq::SamplingAlgorithms::AMProposal::~AMProposal ( )
virtualdefault

Member Function Documentation

◆ Adapt()

void AMProposal::Adapt ( unsigned int const  t,
std::vector< std::shared_ptr< SamplingState >> const &  states 
)
overridevirtual

Adapt the proposal after each step.

Adapt the proposal covariance.

Parameters
[in]tThe current step
[in]stateThe current state

Reimplemented from muq::SamplingAlgorithms::MCMCProposal.

Reimplemented in muq::SamplingAlgorithms::ParallelAMProposal.

Definition at line 43 of file AMProposal.cpp.

References adaptEnd, adaptStart, adaptSteps, muq::SamplingAlgorithms::MCMCProposal::blockInd, mean, newSamps, numAdaptSamps, numNewSamps, and propChol.

Referenced by muq::SamplingAlgorithms::ParallelAMProposal::Adapt().

◆ ConstructCovariance()

Eigen::MatrixXd AMProposal::ConstructCovariance ( boost::property_tree::ptree const &  pt,
std::shared_ptr< AbstractSamplingProblem > const &  prob 
)
staticprivate

Definition at line 34 of file AMProposal.cpp.

References muq::SamplingAlgorithms::MCMCProposal::prob.

◆ LogDensity()

double AMProposal::LogDensity ( std::shared_ptr< SamplingState > const &  currState,
std::shared_ptr< SamplingState > const &  propState 
)
overrideprivatevirtual

◆ ProposalCovariance()

Eigen::MatrixXd AMProposal::ProposalCovariance ( ) const
virtual

Returns the current proposal covariance.

Definition at line 79 of file AMProposal.cpp.

References adaptScale, numAdaptSamps, and propChol.

◆ Sample()

std::shared_ptr< SamplingState > AMProposal::Sample ( std::shared_ptr< SamplingState > const &  currentState)
overrideprivatevirtual

Member Data Documentation

◆ adaptEnd

const unsigned int muq::SamplingAlgorithms::AMProposal::adaptEnd
private

After how many iterations should we stop adapting?

Definition at line 85 of file AMProposal.h.

Referenced by Adapt().

◆ adaptScale

const double muq::SamplingAlgorithms::AMProposal::adaptScale
private

Definition at line 88 of file AMProposal.h.

Referenced by LogDensity(), ProposalCovariance(), and Sample().

◆ adaptStart

const unsigned int muq::SamplingAlgorithms::AMProposal::adaptStart
private

When should we start adapting?

Definition at line 82 of file AMProposal.h.

Referenced by Adapt().

◆ adaptSteps

const unsigned int muq::SamplingAlgorithms::AMProposal::adaptSteps
private

How frequently should we update the adaption?

Definition at line 79 of file AMProposal.h.

Referenced by Adapt().

◆ mean

Eigen::VectorXd muq::SamplingAlgorithms::AMProposal::mean
private

The current mean.

Definition at line 70 of file AMProposal.h.

Referenced by Adapt().

◆ newSamps

Eigen::MatrixXd muq::SamplingAlgorithms::AMProposal::newSamps
private

Samples seen between visits.

Definition at line 63 of file AMProposal.h.

Referenced by Adapt().

◆ numAdaptSamps

unsigned int muq::SamplingAlgorithms::AMProposal::numAdaptSamps =0
private

Total number of samples that have been used so far to compute mean and covariance.

Definition at line 67 of file AMProposal.h.

Referenced by Adapt(), LogDensity(), ProposalCovariance(), and Sample().

◆ numNewSamps

unsigned int muq::SamplingAlgorithms::AMProposal::numNewSamps =0
private

Definition at line 64 of file AMProposal.h.

Referenced by Adapt().

◆ propChol

Eigen::LLT<Eigen::MatrixXd, Eigen::Lower> muq::SamplingAlgorithms::AMProposal::propChol
private

The Cholesky factorization of the current proposal covariance.

Definition at line 76 of file AMProposal.h.

Referenced by Adapt(), LogDensity(), ProposalCovariance(), and Sample().

◆ propCov

Eigen::MatrixXd muq::SamplingAlgorithms::AMProposal::propCov
private

The current proposal covariance.

Definition at line 73 of file AMProposal.h.


The documentation for this class was generated from the following files: