#include <GlobalRng.h>
Static Public Member Functions | |
| static void | seed (long s) |
| Sets the seed for all random number generators to "s". | |
Static Public Attributes | |
| static Bernoulli | coinToss |
| Instance of class Bernoulli:. | |
| static DiscreteUniform | discrete |
| Instance of class DiscreteUniform:. | |
| static Uniform | uni |
| Instance of class Uniform:. | |
| static Normal | gauss |
| Instance of class Normal:. | |
| static Cauchy | cauchy |
| Instance of class Cauchy:. | |
| static Geometric | geom |
| Instance of class Geometric:. | |
| static DiffGeometric | diffGeom |
| Instance of class DiffGeometric:. | |
| static Poisson | poisson |
| Instance of class Poisson:. | |
This class instantiates the following classes at once:
Additionally, the seed for all the random number generators listed above can be set by calling a single method.
#include "Rng/GlobalRng.h" void main() { // We need only one instance to get several // random number generators: Rng rng; // Set seed for all subsumed random number generators: rng.seed( 1234 ); // Get random "numbers" for all subsumed random number generators: bool rn1 = rng.coinToss( ); long rn2 = rng.discrete( ); double rn3 = rng.uni( ); double rn4 = rng.gauss( ); double rn5 = rng.cauchy( ); long rn6 = rng.geom( ); long rn7 = rng.diffGeom( ); // Output of random numbers: cout << "Bernoulli trial = " << rn1 << endl; cout << "Discrete distribution number = " << rn2 << endl; cout << "Uniform distribution number = " << rn3 << endl; cout << "Normal distribution number = " << rn4 << endl; cout << "Cauchy distribution number = " << rn5 << endl; cout << "Geometric distribution number = " << rn6 << endl; cout << "Differential Geometric distribution number = " << rn7 << endl; }
| void Rng::seed | ( | long | s | ) | [static] |
Sets the seed for all random number generators to "s".
Sets the seed for all random number generators to "s".
| s | the seed for the random number generators in this class |
1.5.6