MUQ  0.4.3
RandomVariable.cpp
Go to the documentation of this file.
2 
3 using namespace muq::Modeling;
4 
5 
6 RandomVariable::RandomVariable(std::shared_ptr<Distribution> distIn) : Distribution(distIn->varSize, distIn->hyperSizes),
7  ModPiece(distIn->hyperSizes,
8  distIn->varSize*Eigen::VectorXi::Ones(1)),
9  dist(distIn)
10 {
11  assert(dist);
12 }
13 
14 
16 {
17  outputs.resize(1);
18  outputs.at(0) = dist->Sample(inputs);
19 }
20 
22 {
23  return dist->LogDensity(inputs);
24 };
25 
26 Eigen::VectorXd RandomVariable::GradLogDensityImpl(unsigned int wrt, ref_vector<Eigen::VectorXd> const& inputs)
27 {
28  return dist->GradLogDensity(wrt, inputs);
29 }
30 
32 {
33  return dist->Sample(inputs);
34 }
Provides an abstract interface for defining vector-valued model components.
Definition: ModPiece.h:148
std::vector< Eigen::VectorXd > outputs
Definition: ModPiece.h:503
virtual Eigen::VectorXd GradLogDensityImpl(unsigned int wrt, ref_vector< Eigen::VectorXd > const &inputs) override
virtual Eigen::VectorXd SampleImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Sample the distribution.
virtual double LogDensityImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Implement the log-density.
std::shared_ptr< Distribution > dist
virtual void EvaluateImpl(ref_vector< Eigen::VectorXd > const &inputs) override
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37