#include <Distribution.h>
Definition at line 18 of file Distribution.h.
Public Member Functions | |
Distribution (unsigned int varSizeIn, Eigen::VectorXi const &hyperSizesIn=Eigen::VectorXi()) | |
virtual | ~Distribution ()=default |
virtual double | LogDensity (ref_vector< Eigen::VectorXd > const &inputs) |
Evaluate the log-density. More... | |
virtual double | LogDensity (std::vector< Eigen::VectorXd > const &inputs) |
VARIADIC_TO_REFVECTOR (LogDensity, Eigen::VectorXd, double) | |
virtual Eigen::VectorXd | GradLogDensity (unsigned int wrt, std::vector< Eigen::VectorXd > const &inputs) |
virtual Eigen::VectorXd | GradLogDensity (unsigned int wrt, ref_vector< Eigen::VectorXd > const &inputs) |
template<typename... Args> | |
Eigen::VectorXd | GradLogDensity (unsigned int wrt, Args... args) |
virtual Eigen::VectorXd | ApplyLogDensityHessian (unsigned int const inWrt1, unsigned int const inWrt2, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec) |
virtual Eigen::VectorXd | ApplyLogDensityHessian (unsigned int const inWrt1, unsigned int const inWrt2, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec) |
Eigen::VectorXd | Sample (ref_vector< Eigen::VectorXd > const &inputs) |
Sample the distribution. More... | |
Eigen::VectorXd | Sample (std::vector< Eigen::VectorXd > const &inputs) |
Eigen::VectorXd | Sample () |
Sample the distribution with no inputs. More... | |
VARIADIC_TO_REFVECTOR (Sample, Eigen::VectorXd, Eigen::VectorXd) | |
std::shared_ptr< Density > | AsDensity () |
Returns a density built from this distribution. More... | |
std::shared_ptr< RandomVariable > | AsVariable () |
Returns a random variable built from this distribution. More... | |
Public Attributes | |
const unsigned int | varSize |
const Eigen::VectorXi | hyperSizes |
Friends | |
class | Density |
class | RandomVariable |
|
inline |
Definition at line 23 of file Distribution.h.
|
virtualdefault |
|
virtual |
Reimplemented in muq::Modeling::Gamma.
Definition at line 76 of file Distribution.cpp.
References ApplyLogDensityHessianImpl(), hyperSizes, and varSize.
Referenced by muq::Modeling::DensityBase::ApplyHessianImpl(), and ApplyLogDensityHessian().
|
inlinevirtual |
Definition at line 56 of file Distribution.h.
References ApplyLogDensityHessian(), and ToRefVector().
|
protectedvirtual |
Reimplemented in muq::Modeling::GaussianBase, muq::Modeling::DensityProduct, and muq::Modeling::Density.
Definition at line 93 of file Distribution.cpp.
References nlohmann::detail::dtoa_impl::e, and GradLogDensity().
Referenced by ApplyLogDensityHessian().
std::shared_ptr< Density > Distribution::AsDensity | ( | ) |
Returns a density built from this distribution.
The distribution class allows users to both evaluate the density corresponding to a probability distribution and draw a sample of the corresponding random variable. Both of these actions are supported through the Evaluate function, where the first input to Evaluate specifies what action to perform: evaluate the density or sample the RV. However, sometimes we only want to focus on the density part of the distribution. This function returns a Density object that only supports evaluting the log density and does not require the extra input specifying what type of action to perform.
For example,
Definition at line 9 of file Distribution.cpp.
std::shared_ptr< RandomVariable > Distribution::AsVariable | ( | ) |
Returns a random variable built from this distribution.
The distribution class allows users to both evaluate the density corresponding to a probability distribution and draw a sample of the corresponding random variable. Both of these actions are supported through the Evaluate function, where the first input to Evaluate specifies what action to perform: evaluate the density or sample the RV. However, sometimes we only want to focus on the random variable part (i.e., the "Sample" function) of the distribution. This function returns a RandomVariable object that only supports drawing realizations of the distribution, not evaluting the density. Because the RandomVariable only does one thing, it does not require the extra input specifying what type of action to perform.
For example,
Definition at line 14 of file Distribution.cpp.
|
inline |
Definition at line 44 of file Distribution.h.
References GradLogDensity().
|
inlineprivate |
Definition at line 180 of file Distribution.h.
References GradLogDensity().
|
virtual |
Reimplemented in muq::Modeling::Gamma.
Definition at line 44 of file Distribution.cpp.
References GradLogDensityImpl().
|
inlinevirtual |
Definition at line 40 of file Distribution.h.
References GradLogDensity(), and ToRefVector().
Referenced by muq::Modeling::DensityBase::ApplyHessianImpl(), muq::Modeling::DensityBase::ApplyJacobianImpl(), ApplyLogDensityHessianImpl(), muq::Modeling::DensityBase::GradientImpl(), GradLogDensity(), and muq::Modeling::DensityBase::JacobianImpl().
|
protectedvirtual |
Reimplemented in muq::Modeling::RandomVariable, muq::Modeling::MixtureDistribution, muq::Modeling::GaussianBase, muq::Modeling::DensityProduct, and muq::Modeling::Density.
Definition at line 50 of file Distribution.cpp.
References nlohmann::detail::dtoa_impl::e, and LogDensity().
Referenced by GradLogDensity().
|
virtual |
Evaluate the log-density.
If known, the log-density should be implemented by a child in the LogDensityImpl class.
[in] | inputs | the vector of inputs to the log-density |
Definition at line 31 of file Distribution.cpp.
References LogDensityImpl().
Referenced by muq::Modeling::DensityBase::EvaluateImpl(), GradLogDensityImpl(), muq::SamplingAlgorithms::InverseGammaProposal::LogDensity(), and muq::SamplingAlgorithms::SMMALAProposal::LogDensity().
|
inlinevirtual |
Definition at line 36 of file Distribution.h.
References LogDensity(), and ToRefVector().
Referenced by LogDensity().
|
inlineprotectedvirtual |
Implement the log-density.
If known, the log-density should be implemented by a child. If it is not overridden then the default behavior is to return negative infinity (-1.0*std::numeric_limits<double>::infinity()).
[in] | inputs | the vector of inputs to the log-density |
Reimplemented in muq::Modeling::UniformBox, muq::Modeling::RandomVariable, muq::Modeling::PyDistribution, muq::Modeling::MixtureDistribution, muq::Modeling::InverseGamma, muq::Modeling::GaussianBase, muq::Modeling::Gamma, muq::Modeling::DensityProduct, and muq::Modeling::Density.
Definition at line 156 of file Distribution.h.
Referenced by LogDensity().
Eigen::VectorXd Distribution::Sample | ( | ) |
Sample the distribution with no inputs.
Allows the user to call Sample without any inputs
Definition at line 40 of file Distribution.cpp.
Eigen::VectorXd Distribution::Sample | ( | ref_vector< Eigen::VectorXd > const & | inputs | ) |
Sample the distribution.
Calls SampleImpl, the default behavior is to return boost::none
[in] | inputs | the vector of inputs to the log-density |
Definition at line 36 of file Distribution.cpp.
References SampleImpl().
Referenced by muq::SamplingAlgorithms::InverseGammaProposal::Sample(), and muq::SamplingAlgorithms::SMMALAProposal::Sample().
|
inline |
Definition at line 69 of file Distribution.h.
References Sample(), and ToRefVector().
Referenced by Sample().
|
inlineprotectedvirtual |
Sample the distribution.
Should be overwritten by a child. The default behavior is to return boost::none
Reimplemented in muq::Modeling::UniformBox, muq::Modeling::RandomVariable, muq::Modeling::PyDistribution, muq::Modeling::MixtureDistribution, muq::Modeling::InverseGamma, muq::Modeling::GaussianBase, muq::Modeling::Gamma, and muq::Modeling::Density.
Definition at line 170 of file Distribution.h.
Referenced by Sample().
|
protected |
Definition at line 19 of file Distribution.cpp.
Referenced by ApplyLogDensityHessian(), GradLogDensity(), LogDensity(), and Sample().
muq::Modeling::Distribution::VARIADIC_TO_REFVECTOR | ( | LogDensity | , |
Eigen::VectorXd | , | ||
double | |||
) |
muq::Modeling::Distribution::VARIADIC_TO_REFVECTOR | ( | Sample | , |
Eigen::VectorXd | , | ||
Eigen::VectorXd | |||
) |
|
friend |
Definition at line 20 of file Distribution.h.
|
friend |
Definition at line 21 of file Distribution.h.
const Eigen::VectorXi muq::Modeling::Distribution::hyperSizes |
Definition at line 146 of file Distribution.h.
Referenced by ApplyLogDensityHessian(), muq::Modeling::MixtureDistribution::GradLogDensityImpl(), and muq::Modeling::MixtureDistribution::MixtureDistribution().
const unsigned int muq::Modeling::Distribution::varSize |
Definition at line 145 of file Distribution.h.
Referenced by ApplyLogDensityHessian(), muq::Modeling::MixtureDistribution::GradLogDensityImpl(), and muq::Modeling::MixtureDistribution::MixtureDistribution().