VPTissue Reference Manual
SimPT_Sim::RandomEngine Class Reference

Creates a random generator based on a seed. More...

#include <RandomEngine.h>

Collaboration diagram for SimPT_Sim::RandomEngine:
Collaboration graph

Public Member Functions

 RandomEngine ()
 Initializes to default engine( trng::mrg2 with seed 1).
 
template<typename D >
std::function< typename D::result_type()> GetGenerator (const D &d, int i=0)
 Produce a random generator out of a distribution bound to sim's random engine. More...
 
RandomEngineType::Info GetInfo () const
 Return the state of the random engine.
 
bool Reinitialize ()
 Reset to the default engine (trng::mrg2 with seed 1).
 
bool Reinitialize (const boost::property_tree::ptree &ptree)
 Reset to engine defined by the data packed in ptree.
 

Detailed Description

Creates a random generator based on a seed.

Internally, TRNG is used since: "However, there is a crucial difference between TRNG distributions and C++11 distri butions. TRNG distributions consume exactly one random number from a random number engine to generated a random number from a desired distribution. With C++11 distributions the number of consumed random numbers may be larger or may even vary. Thus, C++11 random number distributions should not be utilized in parallel Monte Carlo simulations. In particular, it is not possible to write parallel Monte Carlo simulations that play fair, see section 2.3."

Definition at line 48 of file RandomEngine.h.

Member Function Documentation

template<typename D >
std::function<typename D::result_type()> SimPT_Sim::RandomEngine::GetGenerator ( const D &  d,
int  i = 0 
)
inline

Produce a random generator out of a distribution bound to sim's random engine.

Parameters
dThe distribution object.
iWhich thread is requesting the generator, 0 by default.
Returns
The random generator g that can be called as g()

Definition at line 68 of file RandomEngine.h.


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