COPASI API  4.40.278
CRandom Class Reference

#include <CRandom.h>

Inheritance diagram for CRandom:
[legend]

Classes

struct  ExpVars
 
struct  PoissonVars
 

Public Types

enum  Type { r250 = 0 , mt19937 , mt19937HR , unkown }
 

Public Member Functions

CRandomcopy ()
 
const unsigned C_INT32getModulus () const
 
virtual C_FLOAT64 getRandomCC ()
 
virtual C_FLOAT64 getRandomCO ()
 
virtual C_FLOAT64 getRandomExp ()
 
virtual C_FLOAT64 getRandomGamma (C_FLOAT64 shape, C_FLOAT64 scale)
 
virtual C_FLOAT64 getRandomNormal (const C_FLOAT64 &mean, const C_FLOAT64 &sd)
 
virtual C_FLOAT64 getRandomNormal01 ()
 
virtual C_FLOAT64 getRandomNormalLog (const C_FLOAT64 &mean, const C_FLOAT64 &sd)
 
virtual C_FLOAT64 getRandomNormalPositive (const C_FLOAT64 &mean, const C_FLOAT64 &sd)
 
virtual C_FLOAT64 getRandomOO ()
 
virtual C_FLOAT64 getRandomPoisson (const C_FLOAT64 &mean)
 
virtual C_INT32 getRandomS ()
 
virtual C_INT32 getRandomS (const C_INT32 &max)
 
virtual C_FLOAT64 getRandomStdGamma (C_FLOAT64 shape)
 
virtual unsigned C_INT32 getRandomU ()
 
virtual unsigned C_INT32 getRandomU (const unsigned C_INT32 &max)
 
const CRandom::TypegetType () const
 
virtual void initialize (unsigned C_INT32 seed=CRandom::getSystemSeed())
 
virtual ~CRandom ()
 

Static Public Member Functions

static CRandomcreateGenerator (CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
 
static unsigned C_INT32 getSystemSeed ()
 

Static Public Attributes

static const std::string TypeName []
 
static const char * XMLType []
 

Protected Member Functions

 CRandom ()
 
void setModulus (const unsigned C_INT32 &modulus)
 

Protected Attributes

C_FLOAT64 mFloat
 
unsigned C_INT32 mModulus
 
C_FLOAT64 mModulusInv
 
C_FLOAT64 mModulusInv1
 
C_INT32 mNumberS
 
unsigned C_INT32 mNumberU
 
CRandom::Type mType
 

Private Member Functions

C_FLOAT64 fsign (C_FLOAT64 num, C_FLOAT64 sign)
 
unsigned int & syscall (int arg1)
 

Private Attributes

ExpVars vare
 
PoissonVars varp
 

Member Enumeration Documentation

◆ Type

Enumerator
r250 
mt19937 
mt19937HR 
unkown 

Constructor & Destructor Documentation

◆ CRandom()

◆ ~CRandom()

CRandom::~CRandom ( )
virtual

The destructor.

Member Function Documentation

◆ copy()

CRandom * CRandom::copy ( )

Create a copy of the generator

References createGenerator(), getRandomU(), and mType.

◆ createGenerator()

CRandom * CRandom::createGenerator ( CRandom::Type  type = CRandom::mt19937,
unsigned C_INT32  seed = 0 
)
static

◆ fsign()

C_FLOAT64 CRandom::fsign ( C_FLOAT64  num,
C_FLOAT64  sign 
)
private

Referenced by getRandomPoisson().

◆ getModulus()

const unsigned C_INT32 & CRandom::getModulus ( ) const

Retreive the method dependend modulus

Returns
const unsigned C_INT32 & modulus

References mModulus.

◆ getRandomCC()

◆ getRandomCO()

C_FLOAT64 CRandom::getRandomCO ( )
virtual

Produces a uniformly distributed random number in 0 <= x < 1. Note: 0 < x <= 1 may be achieved by 1.0 - getRandomCO().

Returns
C_FLOAT64 random

Reimplemented in Cr250, Cmt19937HR, and Cmt19937.

References getRandomU(), and mModulusInv1.

Referenced by COptMethodCoranaWalk::optimise(), and COptMethodSA::optimise().

◆ getRandomExp()

◆ getRandomGamma()

C_FLOAT64 CRandom::getRandomGamma ( C_FLOAT64  shape,
C_FLOAT64  scale 
)
virtual

◆ getRandomNormal()

C_FLOAT64 CRandom::getRandomNormal ( const C_FLOAT64 mean,
const C_FLOAT64 sd 
)
virtual

Produces a Normally distributed random number with Mean=mean and SD=sd

Parameters
constC_FLOAT64 & mean
constC_FLOAT64 & sd
Returns
C_FLOAT64 random

References getRandomNormal01().

Referenced by COptMethodPS::create(), getRandomNormalPositive(), COptItem::getRandomValue(), and CEvaluationNodeFunction::rnormal().

◆ getRandomNormal01()

C_FLOAT64 CRandom::getRandomNormal01 ( )
virtual

Produces a Normally distributed random number with mean=0 and SD=1

Returns
C_FLOAT64 random

References C_FLOAT64, and getRandomOO().

Referenced by getRandomNormal(), getRandomNormalLog(), getRandomPoisson(), getRandomStdGamma(), and CScanItemRandom::step().

◆ getRandomNormalLog()

C_FLOAT64 CRandom::getRandomNormalLog ( const C_FLOAT64 mean,
const C_FLOAT64 sd 
)
virtual

Produces a Normally distributed random number with Mean=mean and SD=sd in Logarithmic scale

Returns
C_FLOAT64 random

References getRandomNormal01().

◆ getRandomNormalPositive()

C_FLOAT64 CRandom::getRandomNormalPositive ( const C_FLOAT64 mean,
const C_FLOAT64 sd 
)
virtual

Produces a Strictly Positive Normally distributed random number with Mean=mean and SD=sd

Parameters
constC_FLOAT64 & mean
constC_FLOAT64 & sd
Returns
C_FLOAT64 random

References C_FLOAT64, and getRandomNormal().

◆ getRandomOO()

◆ getRandomPoisson()

C_FLOAT64 CRandom::getRandomPoisson ( const C_FLOAT64 mean)
virtual

Produces a Poisson distributed random number with Mean=mean

Parameters
constC_FLOAT64 & mean
Returns
C_FLOAT64 random

References CRandom::PoissonVars::a0, CRandom::PoissonVars::a1, CRandom::PoissonVars::a2, CRandom::PoissonVars::a3, CRandom::PoissonVars::a4, CRandom::PoissonVars::a5, CRandom::PoissonVars::a6, CRandom::PoissonVars::a7, CRandom::PoissonVars::b1, CRandom::PoissonVars::b2, CRandom::PoissonVars::c, CRandom::PoissonVars::c0, CRandom::PoissonVars::c1, CRandom::PoissonVars::c2, CRandom::PoissonVars::c3, CRandom::PoissonVars::d, CRandom::PoissonVars::del, CRandom::PoissonVars::difmuk, CRandom::PoissonVars::e, CRandom::PoissonVars::fact, CRandom::PoissonVars::fk, fsign(), CRandom::PoissonVars::fx, CRandom::PoissonVars::fy, CRandom::PoissonVars::g, getRandomCC(), getRandomExp(), getRandomNormal01(), CRandom::PoissonVars::ignpoi, CRandom::PoissonVars::j, CRandom::PoissonVars::k, CRandom::PoissonVars::kflag, CRandom::PoissonVars::l, CRandom::PoissonVars::ll, CRandom::PoissonVars::m, max, min, CRandom::PoissonVars::muold, CRandom::PoissonVars::muprev, CRandom::PoissonVars::omega, CRandom::PoissonVars::p, CRandom::PoissonVars::p0, CRandom::PoissonVars::pp, CRandom::PoissonVars::px, CRandom::PoissonVars::py, CRandom::PoissonVars::q, CRandom::PoissonVars::s, CRandom::PoissonVars::t, CRandom::PoissonVars::u, CRandom::PoissonVars::v, varp, CRandom::PoissonVars::x, and CRandom::PoissonVars::xx.

Referenced by CTauLeapMethod::doSingleStep(), CTrajAdaptiveSA::doSingleTauLeapStep(), CEvaluationNodeFunction::rpoisson(), and CScanItemRandom::step().

◆ getRandomS() [1/2]

C_INT32 CRandom::getRandomS ( )
virtual

Get a random number in 0 <= n <= (Modulus & 0x7ffffff)

Returns
C_INT32 random

Reimplemented in Cr250, and Cmt19937.

References C_INT32, getRandomU(), min, and mModulus.

◆ getRandomS() [2/2]

C_INT32 CRandom::getRandomS ( const C_INT32 max)
virtual

Get a random number in 0 <= n <= max Note: max must be smaller than Modulus (no check for performance)

Parameters
constC_INT32 & max
Returns
C_INT32 random

References C_INT32, getRandomU(), max, and mModulus.

◆ getRandomStdGamma()

C_FLOAT64 CRandom::getRandomStdGamma ( C_FLOAT64  shape)
virtual

References C_FLOAT64, getRandomNormal01(), and getRandomOO().

Referenced by getRandomGamma().

◆ getRandomU() [1/2]

unsigned C_INT32 CRandom::getRandomU ( )
virtual

◆ getRandomU() [2/2]

unsigned C_INT32 CRandom::getRandomU ( const unsigned C_INT32 max)
virtual

Get a random number in 0 <= n <= max Note: max must be smaller than Modulus (no check for performance)

Parameters
constunsigned C_INT32 & max
Returns
unsigned C_INT32 random

References C_INT32, getRandomU(), max, and mModulus.

◆ getSystemSeed()

unsigned C_INT32 CRandom::getSystemSeed ( )
static

◆ getType()

const CRandom::Type & CRandom::getType ( ) const

Retreive the type of the generator

Returns
const CRandom::Type & type

References mType.

◆ initialize()

void CRandom::initialize ( unsigned C_INT32  seed = CRandom::getSystemSeed())
virtual

Initialize or reinitialize the random number generator with the given seed.

Parameters
unsignedC_INT32 seed (default system seed)

Reimplemented in Cr250, and Cmt19937.

References fatalError.

Referenced by CHybridMethod::start(), CHybridMethodODE45::start(), CStochDirectMethod::start(), CStochMethod::start(), CTauLeapMethod::start(), and CTrajAdaptiveSA::start().

◆ setModulus()

void CRandom::setModulus ( const unsigned C_INT32 modulus)
protected

Set the Modulus

Parameters

References mModulus, mModulusInv, and mModulusInv1.

Referenced by Cmt19937::Cmt19937(), and Cr250::Cr250().

◆ syscall()

unsigned int& CRandom::syscall ( int  arg1)
private

Referenced by getSystemSeed().

Member Data Documentation

◆ mFloat

C_FLOAT64 CRandom::mFloat
protected

◆ mModulus

unsigned C_INT32 CRandom::mModulus
protected

◆ mModulusInv

C_FLOAT64 CRandom::mModulusInv
protected

◆ mModulusInv1

C_FLOAT64 CRandom::mModulusInv1
protected

◆ mNumberS

C_INT32 CRandom::mNumberS
protected

A signed 32-bit integer random number.

◆ mNumberU

unsigned C_INT32 CRandom::mNumberU
protected

◆ mType

CRandom::Type CRandom::mType
protected

The type of the generator

Referenced by copy(), createGenerator(), and getType().

◆ TypeName

const std::string CRandom::TypeName
static
Initial value:
=
{
"r250",
"Mersenne Twister",
"Mersenne Twister (HR)",
""
}

String literals for the GUI to display type names of random number generators known to COPASI.

◆ vare

ExpVars CRandom::vare
private

Referenced by CRandom(), and getRandomExp().

◆ varp

PoissonVars CRandom::varp
private

Referenced by CRandom(), and getRandomPoisson().

◆ XMLType

const char * CRandom::XMLType
static
Initial value:
=
{
"r250",
"MersenneTwister",
"MersenneTwisterHR",
NULL
}

XML type names of random number generators known to COPASI.


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