WELL512¶
This page describes the class WELL512
The class WELL512
is a pretty good pseudo randmom number generator based on a paper by Chris Lomont <http://www.lomont.org/math/papers/2008/Lomont_PRNG_2008.pdf>.
The internal state is defined by a state vector of 16 uint_32 numbers and an index.
- Code:
Public Methods¶
constructor
¶
WELL512(uint32_t *aulState, uint32_t uiIndex=0);
Constructor providing the state and the index
aulState
The state vector, an array of 16 uint32.
uiIndex
The index
constructor
¶
WELL512();
The empty constructor.
destructor
¶
~WELL512();
The destructor.
seed
¶
void seed(uint32_t *aulState, uint32_t uiIndex);
Set a new state vector and index.
aulState
The state vector, an array of 16
uint32
.uiIndex
The current index.
wrand
¶
uint32_t wrand();
Returns a random uint32 in the interval [0, MAX_WRAND].
wrandd
¶
double wrandd();
Retruns a radom double in [0,1).
wrandr
¶
double wrandr(double a, double b);
Return a random double in [a,b).
wrandi
¶
uint32_t wrandi(uint32_t a, uint32_t b, uint32_t s=1);
wrandi(1,9,2)
will return a random odd number between a and b-1wgauss
¶
double wgauss(double dSigma);
Returns a random number with normal distribution around (0) with given sigma
getState
¶
const uint31_t *getState();
Returns a pointer to the state vector.
getIndex
¶
const uint32_t getIndex() const;
Returns the current index.
getCount
¶
unsigned long getCount();
Returns count of random numbers generated.
getSigma
¶
double getSigma();
Returns current sigma.
getPrevNormal
¶
double getPrevNormal();
Returns the previously calculated normal random muber if it exists, else NaN.
setGaussStates
¶
void setGaussStates(double dPrevNormal,double dSigma);
Sets the gauss specific states.
showState
¶
void showState();
Displays the current state
state2String
¶
void state2String(char *pString);
Converts the current state and index to a nice string.
getLastRand
¶
uint32_t getLastRand();
Returns the last random number that was generated.