SST/macro
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
RNG::LFIB4 Class Reference

A lagged Fibonacci random number generator by George Marsaglia (1999; internet posting). More...

#include <rng.h>

Inheritance diagram for RNG::LFIB4:
Inheritance graph
Collaboration diagram for RNG::LFIB4:
Collaboration graph

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 LFIB4construct ()
 
static LFIB4construct (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
UniformIntegerseeder_
 
rngint_t t [256]
 
unsigned char c
 

Detailed Description

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.

Definition at line 400 of file rng.h.

Constructor & Destructor Documentation

RNG::LFIB4::LFIB4 ( )
protected
RNG::LFIB4::~LFIB4 ( )

Member Function Documentation

static LFIB4* RNG::LFIB4::construct ( )
static
static LFIB4* RNG::LFIB4::construct ( const std::vector< rngint_t > &  seeds)
static
int RNG::LFIB4::nseed ( )
virtual

Reimplemented from RNG::Table256.

virtual std::string RNG::LFIB4::to_string ( ) const
inlinevirtual

Definition at line 407 of file rng.h.

rngint_t RNG::LFIB4::value ( )
inlinevirtual

Implements RNG::UniformInteger.

Definition at line 418 of file rng.h.

References RNG::UniformInteger::nseed(), and RNG::UniformInteger::vec_reseed().

Here is the call graph for this function:

void RNG::LFIB4::vec_reseed ( const std::vector< rngint_t > &  seeds)
virtual

Reimplemented from RNG::Table256.


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