Simpact Cyan
Population based event driven simulation using mNRM
exponentialdistribution.h
Go to the documentation of this file.
1 #ifndef EXPONENTIALDISTRIBUTION_H
2 
3 #define EXPONENTIALDISTRIBUTION_H
4 
10 #include <cmath>
11 
18 {
19 public:
21  ExponentialDistribution(double a, GslRandomNumberGenerator *pRng) : ProbabilityDistribution(pRng) { assert(a > 0); m_a = a; }
22 
23  double pickNumber() const;
24  double getA() const { return m_a; }
25 private:
26  double m_a;
27 };
28 
30 {
31  double z = getRandomNumberGenerator()->pickRandomDouble();
32  double y = -std::log(z);
33  double x = y/m_a;
34 
35  return x;
36 }
37 
38 #endif // EXPONENTIALDISTRIBUTION_H
double pickNumber() const
Pick a number according to a specific distrubution, specified in a subclass of ProbabilityDistributio...
Definition: exponentialdistribution.h:29
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:16
This class allows you to return a random number picked from an exponential distribution with specifie...
Definition: exponentialdistribution.h:17
ExponentialDistribution(double a, GslRandomNumberGenerator *pRng)
The constructor specifies parameters for a gamma distribution.
Definition: exponentialdistribution.h:21
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