Simpact Cyan
Population based event driven simulation using mNRM
discretedistributionwrapper.h
1 #ifndef DISCRETEDISTRIBUTIONWRAPPER_H
2 
3 #define DISCRETEDISTRIBUTIONWRAPPER_H
4 
6 #include "booltype.h"
7 #include <string>
8 #include <vector>
9 #include <limits>
10 
11 class DiscreteDistributionFast;
13 
14 class DiscreteDistributionWrapper : public ProbabilityDistribution
15 {
16 public:
17  DiscreteDistributionWrapper(GslRandomNumberGenerator *pRng);
18  ~DiscreteDistributionWrapper();
19 
20  bool_t init(const std::string &csvFileName, double xMin, double xMax, int yCol, bool floor);
21  bool_t init(const std::string &csvFileName, int xCol, int yCol, bool floor);
22  bool_t init(const std::vector<double> &xValues, const std::vector<double> &yValues, bool floor);
23 
24  double pickNumber() const { if (m_pDist == 0) return std::numeric_limits<double>::quiet_NaN(); return m_pDist->pickNumber(); }
25 
26  int getXCol() const { return m_xCol; }
27  int getYCol() const { return m_yCol; }
28  double getXMin() const { return m_xMin; }
29  double getXMax() const { return m_xMax; }
30  std::string getFileName() const { return m_fileName; }
31  bool getFloor() const { return m_floor; }
32 
33  const std::vector<double> &getXValues() const { return m_xValues; }
34  const std::vector<double> &getYValues() const { return m_yValues; }
35 private:
36  ProbabilityDistribution *m_pDist;
37  int m_xCol, m_yCol;
38  double m_xMin, m_xMax;
39  std::string m_fileName;
40  bool m_floor;
41 
42  std::vector<double> m_xValues;
43  std::vector<double> m_yValues;
44 };
45 
46 #endif // DISCRETEDISTRIBUTIONWRAPPER_H
Type to return true/false with error description.
Definition: booltype.h:25
virtual double pickNumber() const =0
Pick a number according to a specific distrubution, specified in a subclass of ProbabilityDistributio...
Helper class to generate random numbers based on some kind of discrete distribution.
Definition: discretedistribution.h:20
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:16
Abstract base class for probability distribution implementations so that they can be used interchange...
Definition: probabilitydistribution.h:15