Go to the first, previous, next, last section, table of contents.


CNFiboG -- Fibonacci RNG

SYNOPSIS

#include <CNCL/FiboG.h>

TYPE

CN_FIBOG

BASE CLASSES

CNRNG

DERIVED CLASSES

None

RELATED CLASSES

CNRandom

DESCRIPTION

CNFiboG is the Fibonacci random number generator class. This generator is a lagged fibonacci generator which is a modification based on the algorithm proposed by Marsaglia, Zaman and Tsang [9]. Concerning the seed selection and the amount of memory required James [10] states the following: "A most exceptional property of this generator is the extreme simplicity of generating independently disjoint sequences. The generator must be initialized by giving one 32-bit integer ..., each value of which gives rise to an independent sequence of sufficient length for an entire calculation. This means that in a collaboration between different physicists, each physicist can be assigned one number between zero and 9999 as the last four decimal digits of the initiator, and he will be assured of not overlapping the sequences of any other, even though he still has about 90000 possibilities for the other digits at his disposal for independent initialization. That is, the program can generate about 900 million different subsequences, each one very long (average length ca. 10^30). On the other hand, there is a small price to pay for the exceptionally long period: The complete specification of the state of the generator at a given point (for example to be able to regenerate a given event in the middle of a calculation) requires one hundred and two full words... This contrasts with the one word (two words) necessary for a MLCG of period ca. 10^9 (10^18)." The implemented version is based on the following algorithm:

  • V_i = (V_i-97 - V_i-37) mod 2^32
  • C_i = (C_i-1 - 362,436,069) mod 2^32
  • D_i = (V_i - C_i) mod 2^32

    The period of this generator is determined by N = (2^32 - 1) * 2^96. For further details and statistical tests of this generator refer to Richter [11].

    The main advantage of this method can be seen in a combination of a simple mathematical formula and a period length sufficient enough for physical simulation runs. Nevertheless, it still represents a pseudo random number generator. Thus, a non-ideal correlation can be expected.

    Constructors:

    CNFiboG(CNParam *param);
    CNFiboG(unsigned long init = 54217137);
    Initializes CNFiboG with a 97 elements circular queue and initial seed.

    In addition to the member functions required by CNCL, CNFiboG provides:

    virtual unsigned long as_long32();
    Draws a random number. The result is an unsigned integer in the range 0 ... 2^32-1.
    virtual bool has_long32();
    Returns TRUE because CNFiboG is able to produce 32bit integer values.
    virtual void reset();
    Resets the CNFiboG to its initial state.
    void seed_internal(unsigned long *ulp);
    Reinitializes the circular queue and cn with *ulp, an array of 98 values.


    Go to the first, previous, next, last section, table of contents.