#include <eosim/dist/distribution.hpp>
Inheritance diagram for eosim::dist::Distribution:
Pseudo-random number generators and distribution play a critical roll in computer simulations. Good generators ensure randomness between runs. So every simulation library must provide these facilities. EoSimulator implements some of the most common distributions and provides one generator, but its design allows more than one generator.
EoSimulator has no fixed number of streams. When a distribution is created, a new generator of user defined type is assigned to it. The generator’s type is defined by a GenType label (GenType is declared together with the NumberGenerator interface). The generator is a Distribution’s private attribute. For example:
NegExpDist my_dist(MT19937, lambda);
// this is a Negative Exponencial Distribution with rate lambda, created using the generator Mt19937
To get a sampled value from a distribution, invoke the operation Distribution::sample on any Distribution’s subclass:
You can also change the generator’s seed with the operation Distribution::setSeed. EoSimulator doesn’t support antithetic streams, but it can be easily implemented.
Public Member Functions | |
Distribution (GenType gen) | |
The constructor creates a Distribution whose generator’s type is gen. | |
virtual | ~Distribution () |
The destructor of Distribution. | |
virtual double | sample ()=0 |
This abstract operation is redefine in concrete distributions and returns a sampled value. | |
void | setSeed (unsigned long seed) |
This operation sets a new seed in the distribution’s number generator. | |
Protected Attributes | |
NumberGenerator * | generator |
Distribution::Distribution | ( | GenType | gen | ) |
The constructor creates a Distribution whose generator’s type is gen.