MUQ  0.4.3
UniformBox.h
Go to the documentation of this file.
1 #ifndef UNIFORMBOX_H_
2 #define UNIFORMBOX_H_
3 
6 
8 
9 
10 namespace muq {
11  namespace Modeling {
12 
83  class UniformBox : public Distribution {
84  public:
85 
86  virtual ~UniformBox() = default;
87 
89 
92  UniformBox(Eigen::MatrixXd const& bounds);
93 
95 
98  template<typename... Args>
99  inline UniformBox(std::pair<double,double> const& pair1, Args... args) : UniformBox(CreateBoundsPairs(pair1, args...)) {}
100 
101  inline UniformBox(std::vector<std::pair<double,double>> const& pairList) : UniformBox(CreateBoundsPairs(pairList)) {}
102 
103  template<typename... Args>
104  inline UniformBox(double lb1, double ub1, Args... args) : UniformBox(CreateBoundsDouble(lb1, ub1, args...)) {}
105 
106  inline UniformBox(std::vector<double> const& bounds) : UniformBox(CreateBoundsDouble(bounds)) {}
107 
108  private:
109 
111 
118  virtual double LogDensityImpl(ref_vector<Eigen::VectorXd> const& inputs) override;
119 
121  virtual Eigen::VectorXd SampleImpl(ref_vector<Eigen::VectorXd> const& inputs) override;
122 
123 
124  //static Eigen::MatrixXd CreateBounds(std::vector<double>& bounds);
125 
126  static Eigen::MatrixXd CreateBoundsPairs(std::vector<std::pair<double,double>> const& bounds);
127  STATIC_VARIADIC_TO_VECTOR(CreateBoundsPairs, (std::pair<double, double>), (Eigen::MatrixXd))
128 
129  static Eigen::MatrixXd CreateBoundsDouble(std::vector<double> const& bounds);
130  STATIC_VARIADIC_TO_VECTOR(CreateBoundsDouble, (double), (Eigen::MatrixXd))
131 
132  //static Eigen::MatrixXd CreateBounds(std::vector<std::pair<double,double>>& bounds);
133  //STATIC_VARIADIC_TO_VECTOR_PART2(CreateBounds, double, (Eigen::MatrixXd))
134 
135 
136 
140  const Eigen::MatrixXd bounds;
141 
142  // Use the values stored in bounds to compute the volume
143  static double ComputeVolume(Eigen::MatrixXd const& boundsIn);
144 
145  // The volume of the region enclosed by the bounds
146  const double volume;
147 
148  };
149  } // namespace Modeling
150 } // namespace muq
151 
152 #endif
Defines a normalized uniform distribution over a bounded rectangular domain.
Definition: UniformBox.h:83
UniformBox(double lb1, double ub1, Args... args)
Definition: UniformBox.h:104
virtual Eigen::VectorXd SampleImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Sample the distribution.
Definition: UniformBox.cpp:61
UniformBox(Eigen::MatrixXd const &bounds)
Create a -dimensional uniform distribution.
Definition: UniformBox.cpp:8
static Eigen::MatrixXd CreateBoundsPairs(std::vector< std::pair< double, double >> const &bounds)
Definition: UniformBox.cpp:20
virtual ~UniformBox()=default
UniformBox(std::vector< std::pair< double, double >> const &pairList)
Definition: UniformBox.h:101
STATIC_VARIADIC_TO_VECTOR(CreateBoundsPairs,(std::pair< double, double >),(Eigen::MatrixXd)) static Eigen static STATIC_VARIADIC_TO_VECTOR(CreateBoundsDouble,(double),(Eigen::MatrixXd)) const Eigen double ComputeVolume(Eigen::MatrixXd const &boundsIn)
A matrix describing the bounding box.
Definition: UniformBox.cpp:15
UniformBox(std::pair< double, double > const &pair1, Args... args)
Create a -dimensional uniform distribution.
Definition: UniformBox.h:99
virtual double LogDensityImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Evaluate the log-density.
Definition: UniformBox.cpp:44
UniformBox(std::vector< double > const &bounds)
Definition: UniformBox.h:106
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37