# cRNG Class Reference
[Random number generation, Extension interface to Envir]

`#include <crng.h>`

Inheritance diagram for cRNG:

List of all members.

## Detailed Description

Abstract interface for random number generator classes.

Some known implementations are `cMersenneTwister`, `cLCG32` and `cAkaroaRNG`. The actual RNG class to be used in simulations can be configured (a feature of the Envir library).

To switch to your own RNG, subclass cRNG, register your new class with the Register_Class() macro, then select it by adding the following to `omnetpp.ini`:

     [General]
     rng-class="MyClass"

See also cModule::rng().

## Public Member Functions

virtual void | initialize (int runNumber, int rngId, int numRngs, int parsimProcId, int parsimNumPartitions, cConfiguration *cfg)=0
virtual void | selfTest ()=0
virtual unsigned long | numbersDrawn ()
virtual unsigned long | intRand ()=0
virtual unsigned long | intRandMax ()=0
virtual unsigned long | intRand (unsigned long n)=0
virtual double | doubleRand ()=0
virtual double | doubleRandNonz ()=0
virtual double | doubleRandIncl1 ()=0
double | doubleRandNonzIncl1 ()

## Member Function Documentation

virtual double cRNG::doubleRand | ( |  | ) | `[pure virtual]`

| Random double on the [0,1) interval.

virtual double cRNG::doubleRandIncl1 | ( |  | ) | `[pure virtual]`

| Random double on the [0,1] interval.

virtual double cRNG::doubleRandNonz | ( |  | ) | `[pure virtual]`

| Random double on the (0,1) interval.

double cRNG::doubleRandNonzIncl1 | ( |  | ) | `[inline]`

| Random double on the (0,1] interval.

virtual void cRNG::initialize | ( | int | runNumber,
|  | int | rngId,
|  | int | numRngs,
|  | int | parsimProcId,
|  | int | parsimNumPartitions,
|  | cConfiguration * | cfg
| ) | `[pure virtual]`

| Called by the simulation framework to set up the RNG at the start of a simulation run. Seed selection should take place here.

virtual unsigned long cRNG::intRand | ( | unsigned long | n | ) | `[pure virtual]`

| Random integer in [0,n), n < intRandMax().

virtual unsigned long cRNG::intRand | ( |  | ) | `[pure virtual]`

| Random integer in the range [0,intRandMax()].

virtual unsigned long cRNG::intRandMax | ( |  | ) | `[pure virtual]`

| Maximum value that can be returned by intRand(), e.g. 2^31-2 with LCG32.

virtual unsigned long cRNG::numbersDrawn | ( |  | ) | `[inline, virtual]`

| Returns how many random numbers have been drawn from this RNG. Subclasses should increment numDrawn in the intRand(), etc. methods.

virtual void cRNG::selfTest | ( |  | ) | `[pure virtual]`

| Coarse test for the correctness of the RNG algorithm. It should detect platform-dependent bugs (e.g. caused by different word size or compiler anomaly). The method should throw an exception if something is wrong. It is invoked only once, when the simulation program starts up.

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

- crng.h