Defines a proposal using the analytic conditional Inverse Gamma distribution for the variance of a Gaussian distribution. More...
#include <InverseGammaProposal.h>
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, MCMCProposalConstructor > | MCMCProposalMap |
Static Public Member Functions inherited from muq::SamplingAlgorithms::MCMCProposal | |
static std::shared_ptr< MCMCProposal > | Construct (boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > const &probIn) |
Static constructor for the transition kernel. More... | |
static std::shared_ptr< MCMCProposalMap > | GetMCMCProposalMap () |
muq::SamplingAlgorithms::InverseGammaProposal::InverseGammaProposal | ( | boost::property_tree::ptree | pt, |
std::shared_ptr< AbstractSamplingProblem > | prob | ||
) |
|
virtualdefault |
|
staticprotected |
Definition at line 155 of file InverseGammaProposal.cpp.
References ExtractInverseGamma(), and muq::SamplingAlgorithms::MCMCProposal::prob.
|
staticprotected |
Definition at line 160 of file InverseGammaProposal.cpp.
References ExtractInverseGamma(), and muq::SamplingAlgorithms::MCMCProposal::prob.
|
staticprotected |
Definition at line 165 of file InverseGammaProposal.cpp.
References muq::SamplingAlgorithms::MCMCProposal::prob.
|
staticprotected |
Definition at line 117 of file InverseGammaProposal.cpp.
References muq::SamplingAlgorithms::MCMCProposal::prob.
Referenced by ExtractAlpha(), and ExtractBeta().
|
staticprotected |
Definition at line 78 of file InverseGammaProposal.cpp.
References muq::SamplingAlgorithms::MCMCProposal::prob.
|
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.
|
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().
|
overrideprotectedvirtual |
Implements muq::SamplingAlgorithms::MCMCProposal.
Definition at line 63 of file InverseGammaProposal.cpp.
References alpha, beta, muq::SamplingAlgorithms::MCMCProposal::blockInd, gaussMean, GetGaussianInput(), muq::Modeling::Distribution::LogDensity(), and varModel.
|
overrideprotectedvirtual |
Implements muq::SamplingAlgorithms::MCMCProposal.
Definition at line 45 of file InverseGammaProposal.cpp.
References alpha, beta, muq::SamplingAlgorithms::MCMCProposal::blockInd, gaussMean, GetGaussianInput(), muq::Modeling::Distribution::Sample(), and varModel.
|
protected |
The prior value of alpha.
Definition at line 54 of file InverseGammaProposal.h.
Referenced by LogDensity(), and Sample().
|
protected |
The prior value of beta.
Definition at line 57 of file InverseGammaProposal.h.
Referenced by LogDensity(), and Sample().
|
protected |
The index of the Gaussian block.
Definition at line 60 of file InverseGammaProposal.h.
Referenced by GetGaussianInput().
|
protected |
The mean of the Gaussian distribution.
Definition at line 66 of file InverseGammaProposal.h.
Referenced by LogDensity(), and Sample().
|
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().