TripleRand


A canopy pseudo-random number generator. Using the Tausworthe exclusive-or shift register, a simple Integer Coungruence generator, and the Hurd 288 total bit shift register, all XOR'd with each other, we provide an engine that should be a fairly good "mother" generator.

This is similar to DualRand, with the addition of the Hurd288Engine. From DualRand, we have the following:

Exclusive or of a feedback shift register and integer congruence random number generator. The feedback shift register uses offsets 127 and 97. The integer congruence generator uses a different multiplier for each stream. The multipliers are chosen to give full period and maximum "potency" for modulo 2^32. The period of the combined random number generator is 2^159 - 2^32, and the sequences are different for each stream (not just started in a different place).

The above is then amended to also add in the exclusive or of the 288-total bit Hurd engine which in this case is a series of 32 interconnected 9-bit shift registers, with the newest bit of each register formed by the XOR of the previous bit and some bit b-d from a previous register where d is chosen to create a primitive polynomial to maximize the period.

Author

Ken Smith

See also

Engines: HepRandomEngine, DRand48Engine , DualRand HepJamesRandom Hurd160Engine Hurd288Engine MTwistEngine RandEngine RanecuEngine RanluxEngine Ranlux64Engine RanshiEngine

Distributions: HepRandom, RandBinomial RandBreitWigner RandChiSquare RandExponential RandFlat RandGamma RandGauss RandGeneral RandPoisson RandStudentT

Declaration

#include "CLHEP/Random/TripleRand.h"

class TripleRand: public HepRandomEngine

Public Member Functions

Constructors
TripleRand()
TripleRand(long seed)
TripleRand(HepInt rowIndex, HepInt colIndex)
TripleRand(std::istream& is)
Copy constructor
TripleRand(const TripleRand & p)
Destructor
virtual ~TripleRand()
Conversion operators
operator HepFloat()
Flat value, without worrying about filling bits

operator unsigned int()
32-bit flat value, quickest of all
=
TripleRand & operator=(const TripleRand & p)
Assignment
Cong
IntegerCong & Cong()
Accessor function, to retrieve the constituent engine for input
ConstCong
const IntegerCong & ConstCong() const
Accessor function, necessary for output
ConstHurd
const Hurd288Engine & ConstHurd() const
Accessor function, necessary for output
ConstTaus
const Tausworthe & ConstTaus() const
Accessor function, necessary for output
flat
HepDouble flat()
Returns a pseudo random number between 0 and 1
flatArray
void flatArray(const HepInt size, HepDouble* vect)
Fills an array vect of specified size with flat random values.
Hurd
Hurd288Engine & Hurd()
Accessor function, to retrieve the constituent engine for input
restoreStatus
void restoreStatus(const char filename[] = "TripleRand.conf")
Reads from named file the last saved engine status and restores it.
saveStatus
void saveStatus(const char filename[] = "TripleRand.conf") const
Saves on named file the current engine status.
setSeed
void setSeed(long seed, HepInt)
Sets the state of the algorithm according to seed.
setSeeds
void setSeeds(const long * seeds, HepInt)
Sets the state of the algorithm according to the zero-terminated array of seeds.
showStatus
void showStatus() const
Dumps the current engine status on the screen.
Taus
Tausworthe & Taus()
Accessor function, to retrieve the constituent engine for input

Non-Member Functions

<<
std::ostream & operator<< (std::ostream & os, const TripleRand & e)
Output to a stream.
>>
std::istream & operator>> (std::istream & is, TripleRand & e)
Input from a stream.

Example

CLHEP/test/testRandom.cc


04 May 1999
EVC