MUQ  0.4.3
muq::Modeling::MixtureDistribution Class Reference

#include <MixtureDistribution.h>

Inheritance diagram for muq::Modeling::MixtureDistribution:

Detailed Description

Definition at line 14 of file MixtureDistribution.h.

Public Member Functions

 MixtureDistribution (std::vector< std::shared_ptr< Distribution >> const &components, Eigen::VectorXd const &probs)
 
virtual ~MixtureDistribution ()=default
 
virtual Eigen::VectorXd GradLogDensityImpl (unsigned int wrt, ref_vector< Eigen::VectorXd > const &inputs) override
 
std::vector< std::shared_ptr< Distribution > > Components ()
 
Eigen::VectorXd Probabilities ()
 
- Public Member Functions inherited from muq::Modeling::Distribution
 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< DensityAsDensity ()
 Returns a density built from this distribution. More...
 
std::shared_ptr< RandomVariableAsVariable ()
 Returns a random variable built from this distribution. More...
 

Additional Inherited Members

- Public Attributes inherited from muq::Modeling::Distribution
const unsigned int varSize
 
const Eigen::VectorXi hyperSizes
 

Constructor & Destructor Documentation

◆ MixtureDistribution()

MixtureDistribution::MixtureDistribution ( std::vector< std::shared_ptr< Distribution >> const &  components,
Eigen::VectorXd const &  probs 
)

Construct a mixture distribution from a list of components and a vector probabilities for each component.

Parameters
[in]componentsList of component distributions
[in]probsVector of probabilities. Must have the same size as components. Probabilities will be normalized to sum to 1.

Definition at line 8 of file MixtureDistribution.cpp.

References components, muq::Modeling::Distribution::hyperSizes, probs, and muq::Modeling::Distribution::varSize.

◆ ~MixtureDistribution()

virtual muq::Modeling::MixtureDistribution::~MixtureDistribution ( )
virtualdefault

Member Function Documentation

◆ Components()

std::vector<std::shared_ptr<Distribution> > muq::Modeling::MixtureDistribution::Components ( )
inline

Returns the vector of component distributions.

Definition at line 36 of file MixtureDistribution.h.

References components.

◆ GradLogDensityImpl()

Eigen::VectorXd MixtureDistribution::GradLogDensityImpl ( unsigned int  wrt,
ref_vector< Eigen::VectorXd > const &  inputs 
)
overridevirtual

Compute the gradient of the log density with respect to either the distribution input or the hyperparameters.

Parameters
[in]wrtSpecifies the index of the variable we wish to take the gradient wrt. If wrt==0, then the gradient should be taken wrt the input variable.
Returns
The gradient of the log density.

Reimplemented from muq::Modeling::Distribution.

Definition at line 59 of file MixtureDistribution.cpp.

References components, muq::Modeling::Distribution::hyperSizes, probs, and muq::Modeling::Distribution::varSize.

◆ LogDensityImpl()

double MixtureDistribution::LogDensityImpl ( ref_vector< Eigen::VectorXd > const &  inputs)
overrideprotectedvirtual

Compute the log density.

Parameters
[in]Avector of extra hyperparameter vectors.
Returns
A double containing the log density.

Reimplemented from muq::Modeling::Distribution.

Definition at line 50 of file MixtureDistribution.cpp.

References components, and probs.

◆ Probabilities()

Eigen::VectorXd muq::Modeling::MixtureDistribution::Probabilities ( )
inline

Returns the probability vector.

Definition at line 39 of file MixtureDistribution.h.

References probs.

◆ SampleImpl()

Eigen::VectorXd MixtureDistribution::SampleImpl ( ref_vector< Eigen::VectorXd > const &  inputs)
overrideprotectedvirtual

Sample the distribution.

Reimplemented from muq::Modeling::Distribution.

Definition at line 77 of file MixtureDistribution.cpp.

References components, and probs.

Member Data Documentation

◆ components

std::vector<std::shared_ptr<Distribution> > muq::Modeling::MixtureDistribution::components
protected

◆ probs

Eigen::VectorXd muq::Modeling::MixtureDistribution::probs
protected

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