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:.
static Gamma gam
 Instance of class Gamma:.
static Dirichlet dir
 Instance of class Dirichlet:.


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

Definition at line 129 of file GlobalRng.h.


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
Examples:
RngTest2.cpp.

Definition at line 99 of file GlobalRng.cpp.

References cauchy, coinToss, diffGeom, dir, discrete, gam, gauss, geom, poisson, Dirichlet::seed(), Gamma::seed(), Normal::seed(), RandomVar< T >::seed(), and uni.


Member Data Documentation

Cauchy Rng::cauchy [static]

Instance of class Cauchy:.

Definition at line 146 of file GlobalRng.h.

Referenced by seed().

Instance of class Bernoulli:.

Definition at line 134 of file GlobalRng.h.

Referenced by seed().

Instance of class DiffGeometric:.

Definition at line 152 of file GlobalRng.h.

Referenced by seed().

Dirichlet Rng::dir [static]

Instance of class Dirichlet:.

Definition at line 161 of file GlobalRng.h.

Referenced by seed().

Instance of class DiscreteUniform:.

Examples:
RngTest2.cpp.

Definition at line 137 of file GlobalRng.h.

Referenced by seed().

Gamma Rng::gam [static]

Instance of class Gamma:.

Definition at line 158 of file GlobalRng.h.

Referenced by seed().

Normal Rng::gauss [static]

Instance of class Normal:.

Definition at line 143 of file GlobalRng.h.

Referenced by seed().

Geometric Rng::geom [static]

Instance of class Geometric:.

Definition at line 149 of file GlobalRng.h.

Referenced by seed().

Instance of class Poisson:.

Definition at line 155 of file GlobalRng.h.

Referenced by seed().

Uniform Rng::uni [static]

Instance of class Uniform:.

Definition at line 140 of file GlobalRng.h.

Referenced by seed().


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