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 private:
25  double m_range, m_offset;
26 };
27 
28 inline UniformDistribution::UniformDistribution(double minValue, double maxValue, GslRandomNumberGenerator *pRng) : ProbabilityDistribution(pRng)
29 {
30  m_range = maxValue-minValue;
31  m_offset = minValue;
32 }
33 
34 inline double UniformDistribution::pickNumber() const
35 {
36  double x = getRandomNumberGenerator()->pickRandomDouble();
37  return x*m_range + m_offset;
38 }
39 
40 #endif // UNIFORMDISTRIBUTION_H
41 
double pickNumber() const
Pick a number according to a specific distrubution, specified in a subclass of ProbabilityDistributio...
Definition: uniformdistribution.h:34
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:28