Simpact Cyan
Population based event driven simulation using mNRM
uniformdistribution.h
Go to the documentation of this file.
1 #ifndef UNIFORMDISTRIBUTION_H
2 
3 #define UNIFORMDISTRIBUTION_H
4 
11 
16 {
17 public:
19  UniformDistribution(double minValue, double maxValue, GslRandomNumberGenerator *pRng);
20 
21  double pickNumber() const;
22  double getMin() const { return m_offset; }
23  double getRange() const { return m_range; }
24  double getMax() const { return m_maxValue; }
25 private:
26  double m_range, m_offset, m_maxValue;
27 };
28 
29 inline UniformDistribution::UniformDistribution(double minValue, double maxValue, GslRandomNumberGenerator *pRng) : ProbabilityDistribution(pRng)
30 {
31  m_range = maxValue-minValue;
32  m_offset = minValue;
33  m_maxValue = maxValue;
34 }
35 
36 inline double UniformDistribution::pickNumber() const
37 {
38  double x = getRandomNumberGenerator()->pickRandomDouble();
39  return x*m_range + m_offset;
40 }
41 
42 #endif // UNIFORMDISTRIBUTION_H
43 
double pickNumber() const
Pick a number according to a specific distrubution, specified in a subclass of ProbabilityDistributio...
Definition: uniformdistribution.h:36
This class allows you to return a random number from a uniform distribution with parameters specified...
Definition: uniformdistribution.h:15
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
double pickRandomDouble()
Generate a random floating point number in the interval [0,1].
Definition: gslrandomnumbergenerator.cpp:97
UniformDistribution(double minValue, double maxValue, GslRandomNumberGenerator *pRng)
The constructor specifies parameters for a uniform distribution.
Definition: uniformdistribution.h:29