Rng Class Reference

This class subsumes several often used random number generators. More...

#include <GlobalRng.h>

List of all members.

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:.


Detailed Description

This class subsumes several often used random number generators.

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.

Example
  #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;
  }
This is the way you can use the class and address the single random number generators in it.

Author:
M. Kreutz
Date:
1995-01-01
Changes:
none
Status:
stable

Member Function Documentation

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".

Parameters:
s the seed for the random number generators in this class
Returns:
none
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable
See also:
RandomVar::seed


The documentation for this class was generated from the following files:

Generated on Thu Aug 28 18:34:53 2008 for Dolphin by  doxygen 1.5.6