MUQ  0.4.3
Density.h
Go to the documentation of this file.
1 #ifndef DENSITY_H
2 #define DENSITY_H
3 
6 
7 namespace muq{
8  namespace Modeling{
9 
10  class DensityBase : public Distribution, public ModPiece{
11  public:
12  DensityBase(Eigen::VectorXi const& inputSizes);
13 
14  virtual ~DensityBase() = default;
15 
16  protected:
17 
18  virtual void EvaluateImpl(ref_vector<Eigen::VectorXd> const& inputs) override;
19 
20  virtual void GradientImpl(unsigned int const outputDimWrt,
21  unsigned int const inputDimWrt,
22  ref_vector<Eigen::VectorXd> const& input,
23  Eigen::VectorXd const& sensitivity) override;
24 
25  virtual void JacobianImpl(unsigned int const outputDimWrt,
26  unsigned int const inputDimWrt,
27  ref_vector<Eigen::VectorXd> const& input) override;
28 
29  virtual void ApplyJacobianImpl(unsigned int const outputDimWrt,
30  unsigned int const inputDimWrt,
31  ref_vector<Eigen::VectorXd> const& input,
32  Eigen::VectorXd const& vec) override;
33 
34  virtual void ApplyHessianImpl(unsigned int const outWrt,
35  unsigned int const inWrt1,
36  unsigned int const inWrt2,
37  ref_vector<Eigen::VectorXd> const& input,
38  Eigen::VectorXd const& sens,
39  Eigen::VectorXd const& vec) override;
40 
41  };
42 
43 
44  class Density : public DensityBase{
45 
46  public:
47  Density(std::shared_ptr<Distribution> distIn);
48 
49  virtual ~Density() = default;
50 
51  // Return the distribution this density is built from
52  virtual std::shared_ptr<Distribution> GetDistribution(){ return dist;};
53 
54  protected:
55  std::shared_ptr<Distribution> dist;
56 
57  virtual double LogDensityImpl(ref_vector<Eigen::VectorXd> const& inputs) override;
58 
59  virtual Eigen::VectorXd GradLogDensityImpl(unsigned int wrt,
60  ref_vector<Eigen::VectorXd> const& inputs) override;
61 
62  virtual Eigen::VectorXd ApplyLogDensityHessianImpl(unsigned int const inWrt1,
63  unsigned int const inWrt2,
64  ref_vector<Eigen::VectorXd> const& input,
65  Eigen::VectorXd const& vec) override;
66 
67  virtual Eigen::VectorXd SampleImpl(ref_vector<Eigen::VectorXd> const& inputs) override;
68 
69  static Eigen::VectorXi GetInputSizes(std::shared_ptr<Distribution> distIn);
70 
71  }; // class Density
72 
73  } // namespace Modeling
74 } // namespace muq
75 
76 
77 
78 #endif // #ifndef DENSITY_H
virtual void JacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input) override
Definition: Density.cpp:23
virtual void ApplyJacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec) override
Definition: Density.cpp:31
virtual void ApplyHessianImpl(unsigned int const outWrt, unsigned int const inWrt1, unsigned int const inWrt2, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec) override
Definition: Density.cpp:39
virtual void GradientImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity) override
Definition: Density.cpp:15
DensityBase(Eigen::VectorXi const &inputSizes)
Definition: Density.cpp:5
virtual void EvaluateImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Definition: Density.cpp:9
virtual ~DensityBase()=default
static Eigen::VectorXi GetInputSizes(std::shared_ptr< Distribution > distIn)
Definition: Density.cpp:79
virtual std::shared_ptr< Distribution > GetDistribution()
Definition: Density.h:52
virtual Eigen::VectorXd GradLogDensityImpl(unsigned int wrt, ref_vector< Eigen::VectorXd > const &inputs) override
Definition: Density.cpp:61
virtual ~Density()=default
virtual Eigen::VectorXd SampleImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Sample the distribution.
Definition: Density.cpp:66
std::shared_ptr< Distribution > dist
Definition: Density.h:52
virtual double LogDensityImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Implement the log-density.
Definition: Density.cpp:56
virtual Eigen::VectorXd ApplyLogDensityHessianImpl(unsigned int const inWrt1, unsigned int const inWrt2, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec) override
Definition: Density.cpp:71
Provides an abstract interface for defining vector-valued model components.
Definition: ModPiece.h:148
const Eigen::VectorXi inputSizes
Definition: ModPiece.h:469
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37