Core 1.0
Public Member Functions | List of all members
RandomFast Class Reference

A fast linear congruential random number generator. More...

#include <random.h>

Public Member Functions

 RandomFast (unsigned int=239)
 Create a fast random number generator. More...
 
 RandomFast (int)
 Create a fast random number generator. More...
 
 ~RandomFast ()
 Empty.
 
void Seed (unsigned int)
 Changer the seed of the random number generator. More...
 
void Seed (int)
 Changer the seed of the random number generator. More...
 
unsigned int Integer ()
 Compute a random unsigned integer.
 
unsigned int Integer (int)
 Compute a random unsigned integer within interval [0,a]. More...
 
double Uniform ()
 Compute uniform distribution in [0, 1[.
 
double Uniform (const double &)
 Compute uniform distribution in [0, a[. More...
 
double Uniform (const double &, const double &)
 Compute uniform distribution in [a, b[. More...
 
unsigned int Poisson (const double &)
 Poisson random sequence. More...
 
int Pick (const double *, int)
 Randomly pick one item given an array of probabilities. More...
 

Detailed Description

A fast linear congruential random number generator.

It uses the linear congruential generator xn+1 = 3039177861 xn (mod 232), introduced by Borosh and Niederreiter. This generator is fast and, despite its simplicity, optimal with respect to statistical independence of successive pseudo-random numbers.

See also
RandomMul, RandomXorShift

Constructor & Destructor Documentation

◆ RandomFast() [1/2]

RandomFast::RandomFast ( unsigned int  s = 239)

Create a fast random number generator.

Parameters
sSeed.

◆ RandomFast() [2/2]

RandomFast::RandomFast ( int  s)

Create a fast random number generator.

Parameters
sSeed.

Member Function Documentation

◆ Integer()

unsigned int RandomFast::Integer ( int  a)

Compute a random unsigned integer within interval [0,a].

Parameters
aInteger.

◆ Pick()

int RandomFast::Pick ( const double *  a,
int  n 
)

Randomly pick one item given an array of probabilities.

Parameters
aArray.
nSize.

◆ Poisson()

unsigned int RandomFast::Poisson ( const double &  mu)

Poisson random sequence.

Parameters
muMean value.

◆ Seed() [1/2]

void RandomFast::Seed ( int  s)

Changer the seed of the random number generator.

Parameters
sSeed.

◆ Seed() [2/2]

void RandomFast::Seed ( unsigned int  s)

Changer the seed of the random number generator.

Parameters
sSeed.

◆ Uniform() [1/2]

double RandomFast::Uniform ( const double &  a)

Compute uniform distribution in [0, a[.

Parameters
aAmplitude.

◆ Uniform() [2/2]

double RandomFast::Uniform ( const double &  a,
const double &  b 
)

Compute uniform distribution in [a, b[.

Parameters
a,bAmplitude interval.