SST/macro
|
A lagged Fibonacci random number generator by George Marsaglia (1999; internet posting). More...
#include <rng.h>
Public Member Functions | |
virtual std::string | to_string () const |
rngint_t | value () |
~LFIB4 () | |
void | vec_reseed (const std::vector< rngint_t > &seeds) |
int | nseed () |
Public Member Functions inherited from RNG::Table256 | |
~Table256 () | |
Public Member Functions inherited from RNG::UniformInteger | |
virtual | ~UniformInteger () |
rngint_t | value_in_range (rngint_t range) |
virtual double | realvalue (bool include_zero=true, bool include_one=true) |
Return a random value in the interval [0,1], (0,1], [0,1), or (0,1) More... | |
void | reseed () |
void | reseed (rngint_t) |
void | reseed (rngint_t, rngint_t) |
void | reseed (rngint_t, rngint_t, rngint_t) |
void | reseed (rngint_t, rngint_t, rngint_t, rngint_t) |
Static Public Member Functions | |
static LFIB4 * | construct () |
static LFIB4 * | construct (const std::vector< rngint_t > &seeds) |
Protected Member Functions | |
LFIB4 () | |
Protected Member Functions inherited from RNG::Table256 | |
Table256 () | |
Additional Inherited Members | |
Protected Attributes inherited from RNG::Table256 | |
UniformInteger * | seeder_ |
rngint_t | t [256] |
unsigned char | c |
A lagged Fibonacci random number generator by George Marsaglia (1999; internet posting).
Here is an excerpt from the posting describing this generator: LFIB4 is an extension of the class that I have previously defined as lagged Fibonacci generators: x(n)=x(n-r) op x(n-s), with the x's in a finite set over which there is a binary operation op, such as +,- on integers mod 232, * on odd such integers, exclusive-or (xor) on binary vectors. Except for those using multiplication, lagged Fibonacci generators fail various tests of randomness, unless the lags are very long. To see if more than two lags would serve to overcome the problems of 2- lag generators using +,- or xor, I have developed the 4-lag generator LFIB4: x(n)=x(n-256)+x(n-179)+x(n-119)+x(n-55) mod 232. Its period is 231*(2256-1), about 2287, and it seems to pass all tests—in particular, those of the kind for which 2-lag generators using +,-,xor seem to fail. For even more confidence in its suitability, LFIB4 can be combined with KISS, with a resulting period of about 2410: just use (KISS+LFIB4) in any C expression.
|
protected |
RNG::LFIB4::~LFIB4 | ( | ) |
|
static |
|
virtual |
Reimplemented from RNG::Table256.
|
inlinevirtual |
|
inlinevirtual |
Implements RNG::UniformInteger.
Definition at line 418 of file rng.h.
References RNG::UniformInteger::nseed(), and RNG::UniformInteger::vec_reseed().
|
virtual |
Reimplemented from RNG::Table256.