Scippy

SoPlex

Sequential object-oriented simPlex

Random Class Reference

Random numbers.Class Random provides random Real variables, i.e. a value variable that gives another value each time it is accessed. It may be used just like an ordinary Real by means of an overloaded cast operator Real()%. More...

#include <random.h>

Public Member Functions

Access
Real next (Real minimum=0.0, Real maximum=1.0)
 returns next random number. More...
 
uint32_t getSeed () const
 returns the initial seed shift More...
 
Modification
void setSeed (uint32_t initshift)
 initialize all seeds of the random number generator. More...
 
Constructors / destructors
 Random (uint32_t randomseed=0)
 default constructor. More...
 
 ~Random ()
 destructor More...
 

Private Member Functions

Helpers
Real next_random ()
 executes KISS random number generator and returns a pseudo random Real value in [0,1]. More...
 

Private Attributes

Data
uint32_t seedshift
 initial shift for random seeds. More...
 
uint32_t lin_seed
 random seed for linear congruential RNS. More...
 
uint32_t xor_seed
 random seed for XOR-shift RNS. More...
 
uint32_t mwc_seed
 random seed Multiple-with-carry RNS. More...
 
uint32_t cst_seed
 random seed shifted for mwc_seed. More...
 

Detailed Description

Random numbers.

Class Random provides random Real variables, i.e. a value variable that gives another value each time it is accessed. It may be used just like an ordinary Real by means of an overloaded cast operator Real()%.

This is an implementation of KISS random number generator developed by George Marsaglia. KISS is combination of three different random number generators:

  • Linear congruential generator
  • Xorshift
  • Lag-1 Multiply-with-carry

KISS has a period of 2^123 and passes all statistical test part of BigCrush-Test of TestU01 [1].

[1] http://dl.acm.org/citation.cfm?doid=1268776.1268777

Definition at line 56 of file random.h.

Constructor & Destructor Documentation

◆ Random()

Random ( uint32_t  randomseed = 0)
explicit

default constructor.

Constructs a new (pseudo) Random variable using randomseed as seed for the random variable's sequence.

Definition at line 153 of file random.h.

References Random::setSeed().

◆ ~Random()

~Random ( )

destructor

Definition at line 159 of file random.h.

Member Function Documentation

◆ getSeed()

uint32_t getSeed ( ) const

returns the initial seed shift

Definition at line 113 of file random.h.

References Random::seedshift.

◆ next()

Real next ( Real  minimum = 0.0,
Real  maximum = 1.0 
)

returns next random number.

Definition at line 102 of file random.h.

References Random::next_random().

◆ next_random()

Real next_random ( )
private

executes KISS random number generator and returns a pseudo random Real value in [0,1].

Definition at line 74 of file random.h.

References Random::cst_seed, RADD, and RSTEP.

Referenced by Random::next(), and Random::setSeed().

◆ setSeed()

void setSeed ( uint32_t  initshift)

initialize all seeds of the random number generator.

Definition at line 124 of file random.h.

References DEFAULT_CST, DEFAULT_LIN, DEFAULT_MWC, DEFAULT_XOR, and Random::next_random().

Referenced by Random::Random().

Member Data Documentation

◆ cst_seed

uint32_t cst_seed
private

random seed shifted for mwc_seed.

Definition at line 67 of file random.h.

Referenced by Random::next_random().

◆ lin_seed

uint32_t lin_seed
private

random seed for linear congruential RNS.

Definition at line 64 of file random.h.

◆ mwc_seed

uint32_t mwc_seed
private

random seed Multiple-with-carry RNS.

Definition at line 66 of file random.h.

◆ seedshift

uint32_t seedshift
private

initial shift for random seeds.

Definition at line 63 of file random.h.

Referenced by Random::getSeed().

◆ xor_seed

uint32_t xor_seed
private

random seed for XOR-shift RNS.

Definition at line 65 of file random.h.