mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Merge pull request #1882 from ojschumann/stats_branch
Implementation of openmc.stats.Mixture distribution
This commit is contained in:
commit
fa500e2896
8 changed files with 166 additions and 17 deletions
|
|
@ -24,6 +24,14 @@ public:
|
|||
virtual double sample(uint64_t* seed) const = 0;
|
||||
};
|
||||
|
||||
using UPtrDist = unique_ptr<Distribution>;
|
||||
|
||||
//! Return univariate probability distribution specified in XML file
|
||||
//! \param[in] node XML node representing distribution
|
||||
//! \return Unique pointer to distribution
|
||||
UPtrDist distribution_from_xml(pugi::xml_node node);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//! A discrete distribution (probability mass function)
|
||||
//==============================================================================
|
||||
|
|
@ -222,12 +230,27 @@ private:
|
|||
vector<double> x_; //! Possible outcomes
|
||||
};
|
||||
|
||||
using UPtrDist = unique_ptr<Distribution>;
|
||||
//==============================================================================
|
||||
//! Mixture distribution
|
||||
//==============================================================================
|
||||
|
||||
class Mixture : public Distribution {
|
||||
public:
|
||||
explicit Mixture(pugi::xml_node node);
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
//! \return Sampled value
|
||||
double sample(uint64_t* seed) const;
|
||||
|
||||
private:
|
||||
// Storrage for probability + distribution
|
||||
using DistPair = std::pair<double, UPtrDist>;
|
||||
|
||||
vector<DistPair>
|
||||
distribution_; //!< sub-distributions + cummulative probabilities
|
||||
};
|
||||
|
||||
//! Return univariate probability distribution specified in XML file
|
||||
//! \param[in] node XML node representing distribution
|
||||
//! \return Unique pointer to distribution
|
||||
UPtrDist distribution_from_xml(pugi::xml_node node);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue