MUQ  0.4.3
muq::SamplingAlgorithms::InverseGammaProposal Class Reference

Defines a proposal using the analytic conditional Inverse Gamma distribution for the variance of a Gaussian distribution. More...

#include <InverseGammaProposal.h>

Inheritance diagram for muq::SamplingAlgorithms::InverseGammaProposal:

Detailed Description

Defines a proposal using the analytic conditional Inverse Gamma distribution for the variance of a Gaussian distribution.

Consider a Metropolis-Within-Gibbs sampler for a problem where the inverse Gamma distribution is used to model the variance of a Gaussian distribution. In that setting, the distribution of the variance given the state of the Gaussian random variable is known analytically and can be sampled from directly. This proposal leverages that fact. It assumes a prior distribution over the variance is given by \(\sigma^2 \sim IG(\alpha,\beta)\) and that the Gaussian random variable has zero mean and covariance \(\simga^2 I\). Then, given an observation of the Gaussian random variable \(x=[x_1,x_2, \ldots, x_N]\), we know that

\[ \sigma^2 | x \sim IG(\alpha + \frac{N}{2}, \beta + \frac{1}{2}\sum_{i=1}^Nx_i^2. \]

This is the proposal density defined by this class.

The class assumes that the provided AbstractSamplingProblem is an instance of the SamplingProblem class, which contains a WorkGraph defining the relationship between the inverse gamma and Gaussian distributions.

Configuration Parameters:

Parameter Key Type Default Value Description
"InverseGammaNode" string - The name of the node in the WorkGraph that contains the InverseGamma density.
"GaussianNode" string - The name of the node in the WorkGraph that contains the Gaussian distribution with a variance input.

Definition at line 43 of file InverseGammaProposal.h.

Public Member Functions

 InverseGammaProposal (boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > prob)
 
virtual ~InverseGammaProposal ()=default
 
- Public Member Functions inherited from muq::SamplingAlgorithms::MCMCProposal
 MCMCProposal (boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > const &probIn)
 
virtual ~MCMCProposal ()=default
 
virtual void Adapt (unsigned int const t, std::vector< std::shared_ptr< SamplingState >> const &state)
 Adapt the proposal after each step. More...
 
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

◆ InverseGammaProposal()

muq::SamplingAlgorithms::InverseGammaProposal::InverseGammaProposal ( boost::property_tree::ptree  pt,
std::shared_ptr< AbstractSamplingProblem prob 
)

◆ ~InverseGammaProposal()

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

Member Function Documentation

◆ ExtractAlpha()

Eigen::VectorXd InverseGammaProposal::ExtractAlpha ( std::shared_ptr< AbstractSamplingProblem prob,
std::string const &  igNode 
)
staticprotected

◆ ExtractBeta()

Eigen::VectorXd InverseGammaProposal::ExtractBeta ( std::shared_ptr< AbstractSamplingProblem prob,
std::string const &  igNode 
)
staticprotected

◆ ExtractGaussInfo()

std::tuple< std::shared_ptr< muq::Modeling::ModPiece >, std::vector< int >, int > InverseGammaProposal::ExtractGaussInfo ( std::shared_ptr< AbstractSamplingProblem prob,
std::string const &  gaussNode 
)
staticprotected

◆ ExtractInverseGamma()

std::shared_ptr< InverseGamma > InverseGammaProposal::ExtractInverseGamma ( std::shared_ptr< AbstractSamplingProblem prob,
std::string const &  igNode 
)
staticprotected

Definition at line 117 of file InverseGammaProposal.cpp.

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

Referenced by ExtractAlpha(), and ExtractBeta().

◆ ExtractMean()

Eigen::VectorXd InverseGammaProposal::ExtractMean ( std::shared_ptr< AbstractSamplingProblem prob,
std::string const &  gaussNode 
)
staticprotected

◆ ExtractVarianceModel()

std::shared_ptr< muq::Modeling::ModPiece > InverseGammaProposal::ExtractVarianceModel ( std::shared_ptr< AbstractSamplingProblem prob,
std::string const &  gaussNode,
std::string const &  igNode 
)
staticprotected

Looks through the graph and constructs a ModPiece that maps the variance parameter to the Gaussian variance. This model allows us to account for cases where the diagonal covariance of the Gaussian is defined piecewise or through some orthogonal matrix. For example, diag_variance = V x, where x is the parameter we're sampling with MCMC.

Definition at line 221 of file InverseGammaProposal.cpp.

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

◆ GetGaussianInput()

Eigen::VectorXd InverseGammaProposal::GetGaussianInput ( std::shared_ptr< SamplingState > const &  currentState) const
protectedvirtual

Computes the current input to the Gaussian distribution.

NOTE: If one-step caching is not enabled, this function may end up duplicating calls to expensive ModPieces.

Definition at line 32 of file InverseGammaProposal.cpp.

References gaussInfo.

Referenced by LogDensity(), and Sample().

◆ LogDensity()

double InverseGammaProposal::LogDensity ( std::shared_ptr< SamplingState > const &  currState,
std::shared_ptr< SamplingState > const &  propState 
)
overrideprotectedvirtual

◆ Sample()

std::shared_ptr< SamplingState > InverseGammaProposal::Sample ( std::shared_ptr< SamplingState > const &  currentState)
overrideprotectedvirtual

Member Data Documentation

◆ alpha

const Eigen::VectorXd muq::SamplingAlgorithms::InverseGammaProposal::alpha
protected

The prior value of alpha.

Definition at line 54 of file InverseGammaProposal.h.

Referenced by LogDensity(), and Sample().

◆ beta

const Eigen::VectorXd muq::SamplingAlgorithms::InverseGammaProposal::beta
protected

The prior value of beta.

Definition at line 57 of file InverseGammaProposal.h.

Referenced by LogDensity(), and Sample().

◆ gaussInfo

std::tuple<std::shared_ptr<muq::Modeling::ModPiece>, std::vector<int>, int> muq::SamplingAlgorithms::InverseGammaProposal::gaussInfo
protected

The index of the Gaussian block.

Definition at line 60 of file InverseGammaProposal.h.

Referenced by GetGaussianInput().

◆ gaussMean

const Eigen::VectorXd muq::SamplingAlgorithms::InverseGammaProposal::gaussMean
protected

The mean of the Gaussian distribution.

Definition at line 66 of file InverseGammaProposal.h.

Referenced by LogDensity(), and Sample().

◆ varModel

std::shared_ptr<muq::Modeling::ModPiece> muq::SamplingAlgorithms::InverseGammaProposal::varModel
protected

A ModPiece containing an orthogonal matrix mapping the parameters to Gaussian variance.

Definition at line 63 of file InverseGammaProposal.h.

Referenced by LogDensity(), and Sample().


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