Update mixture distribution

update storeage of c++ class
  update sampling -> uses std::lower_bound for O(log(N)) sampling of the
distribution
  implemented from_xml_element
  updated settings.rst
  include a mixture in the regression tests
This commit is contained in:
Olaf Schumann 2021-09-23 09:34:11 +00:00
parent 1c219600a1
commit e7fa663b3d
7 changed files with 98 additions and 30 deletions

View file

@ -243,13 +243,17 @@ public:
//! \return Sampled value
double sample(uint64_t* seed) const;
// d and p property
const vector<UPtrDist>& d() const { return d_; }
const vector<double>& p() const { return p_; }
private:
vector<UPtrDist> d_; //!< Pointer to sub-distributions
vector<double> p_; //!< tabulated probability density
vector<double> c_; //!< cumulative distribution
struct Pair {
double cummulative_probability_ {0.0};
UPtrDist distribution_;
// bool operator<(const Pair& o) const {
// return cummulative_probability_ < o.cummulative_probability_;
//}
bool operator<(double p) const { return cummulative_probability_ < p; }
};
vector<Pair> distribution_; //!< sub-distributions + cummulative probabilities
};