BioDynaMo  v1.05.117-b1949764
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
bdm::Random Class Reference

#include <random.h>

Public Member Functions

 Random ()
 
 Random (TRootIOCtor *)
 
 Random (const Random &other)
 
 ~Random ()
 
Randomoperator= (const Random &other)
 
real_t Uniform (real_t max=1.0)
 
real_t Uniform (real_t min, real_t max)
 
template<uint64_t N>
MathArray< real_t, N > UniformArray (real_t max=1.0)
 Returns an array of uniform random numbers in the interval (0, max) More...
 
template<uint64_t N>
MathArray< real_t, N > UniformArray (real_t min, real_t max)
 Returns an array of uniform random numbers in the interval (min, max) More...
 
real_t Gaus (real_t mean=0.0, real_t sigma=1.0)
 
real_t Exp (real_t tau)
 
real_t Landau (real_t mean=0, real_t sigma=1)
 
real_t PoissonD (real_t mean)
 
real_t BreitWigner (real_t mean=0, real_t gamma=1)
 
unsigned Integer (int max)
 
int Binomial (int ntot, real_t prob)
 
int Poisson (real_t mean)
 
MathArray< real_t, 2 > Circle (real_t radius)
 
MathArray< real_t, 3 > Sphere (real_t radius)
 
void SetSeed (uint64_t seed)
 
uint64_t GetSeed () const
 
void SetGenerator (TRandom *new_rng)
 
UniformRng GetUniformRng (real_t min=0, real_t max=1) const
 
GausRng GetGausRng (real_t mean=0, real_t sigma=1) const
 
ExpRng GetExpRng (real_t tau) const
 
LandauRng GetLandauRng (real_t mean=0, real_t sigma=1) const
 
PoissonDRng GetPoissonDRng (real_t mean) const
 
BreitWignerRng GetBreitWignerRng (real_t mean=0, real_t gamma=1) const
 
UserDefinedDistRng1D GetUserDefinedDistRng1D (double(*f)(const double *, const double *), const FixedSizeVector< real_t, 10 > &params, real_t min, real_t max, const char *option=nullptr)
 
UserDefinedDistRng2D GetUserDefinedDistRng2D (double(*f)(const double *, const double *), const FixedSizeVector< real_t, 10 > &params, real_t xmin, real_t xmax, real_t ymin, real_t ymax, const char *option=nullptr)
 
UserDefinedDistRng3D GetUserDefinedDistRng3D (double(*f)(const double *, const double *), const FixedSizeVector< real_t, 10 > &params, real_t xmin, real_t xmax, real_t ymin, real_t ymax, real_t zmin, real_t zmax, const char *option=nullptr)
 
BinomialRng GetBinomialRng (int ntot, real_t prob) const
 
PoissonRng GetPoissonRng (real_t mean) const
 

Private Member Functions

 BDM_CLASS_DEF_NV (Random, 3)
 

Private Attributes

TRandom * generator_ = nullptr
 
std::unordered_map< UserDefinedDist, TF1 * > udd_tf1_map_
 
std::unordered_map< UserDefinedDist, TF2 * > udd_tf2_map_
 
std::unordered_map< UserDefinedDist, TF3 * > udd_tf3_map_
 

Friends

class DistributionRng< real_t >
 
class DistributionRng< int >
 

Detailed Description

Decorator for ROOT's TRandom Uses TRandom3 as default random number generator

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 262 of file random.h.

Constructor & Destructor Documentation

◆ Random() [1/3]

bdm::Random::Random ( )

Definition at line 25 of file random.cc.

◆ Random() [2/3]

bdm::Random::Random ( TRootIOCtor *  )
explicit

Definition at line 28 of file random.cc.

◆ Random() [3/3]

bdm::Random::Random ( const Random other)

Definition at line 31 of file random.cc.

◆ ~Random()

bdm::Random::~Random ( )

Definition at line 35 of file random.cc.

Member Function Documentation

◆ BDM_CLASS_DEF_NV()

bdm::Random::BDM_CLASS_DEF_NV ( Random  ,
 
)
private

◆ Binomial()

int bdm::Random::Binomial ( int  ntot,
real_t  prob 
)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 94 of file random.cc.

◆ BreitWigner()

real_t bdm::Random::BreitWigner ( real_t  mean = 0,
real_t  gamma = 1 
)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 86 of file random.cc.

◆ Circle()

MathArray< real_t, 2 > bdm::Random::Circle ( real_t  radius)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 102 of file random.cc.

◆ Exp()

real_t bdm::Random::Exp ( real_t  tau)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 75 of file random.cc.

◆ Gaus()

real_t bdm::Random::Gaus ( real_t  mean = 0.0,
real_t  sigma = 1.0 
)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 70 of file random.cc.

◆ GetBinomialRng()

BinomialRng bdm::Random::GetBinomialRng ( int  ntot,
real_t  prob 
) const

Returns a random number generator that draws samples from a Binomial distribution with given parameters.

Definition at line 358 of file random.cc.

◆ GetBreitWignerRng()

BreitWignerRng bdm::Random::GetBreitWignerRng ( real_t  mean = 0,
real_t  gamma = 1 
) const

Returns a random number generator that draws samples from a BreitWigner distribution with given parameters.

Definition at line 228 of file random.cc.

◆ GetExpRng()

ExpRng bdm::Random::GetExpRng ( real_t  tau) const

Returns a random number generator that draws samples from a exp distribution with given parameters.

Definition at line 198 of file random.cc.

◆ GetGausRng()

GausRng bdm::Random::GetGausRng ( real_t  mean = 0,
real_t  sigma = 1 
) const

Returns a random number generator that draws samples from a gaus distribution with given parameters.

Definition at line 189 of file random.cc.

◆ GetLandauRng()

LandauRng bdm::Random::GetLandauRng ( real_t  mean = 0,
real_t  sigma = 1 
) const

Returns a random number generator that draws samples from a Landau distribution with given parameters.

Definition at line 207 of file random.cc.

◆ GetPoissonDRng()

PoissonDRng bdm::Random::GetPoissonDRng ( real_t  mean) const

Returns a random number generator that draws samples from a PoissonD distribution with given parameters.

Definition at line 216 of file random.cc.

◆ GetPoissonRng()

PoissonRng bdm::Random::GetPoissonRng ( real_t  mean) const

Returns a random number generator that draws samples from a Poisson distribution with given parameters.

Definition at line 367 of file random.cc.

◆ GetSeed()

uint64_t bdm::Random::GetSeed ( ) const

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 121 of file random.cc.

◆ GetUniformRng()

UniformRng bdm::Random::GetUniformRng ( real_t  min = 0,
real_t  max = 1 
) const

Returns a random number generator that draws samples from a uniform distribution with given parameters.

Definition at line 180 of file random.cc.

◆ GetUserDefinedDistRng1D()

UserDefinedDistRng1D bdm::Random::GetUserDefinedDistRng1D ( double(*)(const double *, const double *)  f,
const FixedSizeVector< real_t, 10 > &  params,
real_t  min,
real_t  max,
const char *  option = nullptr 
)

Returns a random number generator that draws samples from a user-defined distribution specified by parameter function between min and max.
The user-defined distribution must follow the following signature: [](const real_t* x, const real_t* params) { ... } and must return a real_t.
The following call will create a random number generator that will sample from a student-t distribution with r = 1.0. in the interval [-5, 10[.
x is the function variable.

auto distribution = [](const real_t* x, const real_t* params) {
  return ROOT::Math::tdistribution_pdf(*x, 1.0);
};
GetUserDefinedDistRng(distribution, {}, -5, 10);

Instead of hardcoding the parameter 1.0 one can also pass it as second parameter. Up to 10 parameters can be used in the user-defined function.

auto distribution = [](const real_t* x, const real_t* params) {
  return ROOT::Math::tdistribution_pdf(*x, params[0]);
};
GetUserDefinedDistRng(distribution, {1.0}, -5, 10);

For param option have a look at ROOT's TF1::GetRandom documentation.

See also
https://root.cern/doc/master/group__PdfFunc.html
https://root.cern/doc/master/classTF1.html

Warning: At the moment, the use of UserDefinedDistRng1 in parallel regions such as behaviors is likely to have a serious performance impact and we advise to only use it in serial regions.

Definition at line 249 of file random.cc.

◆ GetUserDefinedDistRng2D()

UserDefinedDistRng2D bdm::Random::GetUserDefinedDistRng2D ( double(*)(const double *, const double *)  f,
const FixedSizeVector< real_t, 10 > &  params,
real_t  xmin,
real_t  xmax,
real_t  ymin,
real_t  ymax,
const char *  option = nullptr 
)
See also
Random::GetUserDefinedDistRng1D

Definition at line 288 of file random.cc.

◆ GetUserDefinedDistRng3D()

UserDefinedDistRng3D bdm::Random::GetUserDefinedDistRng3D ( double(*)(const double *, const double *)  f,
const FixedSizeVector< real_t, 10 > &  params,
real_t  xmin,
real_t  xmax,
real_t  ymin,
real_t  ymax,
real_t  zmin,
real_t  zmax,
const char *  option = nullptr 
)
See also
Random::GetUserDefinedDistRng1D

Definition at line 333 of file random.cc.

◆ Integer()

unsigned bdm::Random::Integer ( int  max)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 91 of file random.cc.

◆ Landau()

real_t bdm::Random::Landau ( real_t  mean = 0,
real_t  sigma = 1 
)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 78 of file random.cc.

◆ operator=()

Random & bdm::Random::operator= ( const Random other)

Definition at line 51 of file random.cc.

◆ Poisson()

int bdm::Random::Poisson ( real_t  mean)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 99 of file random.cc.

◆ PoissonD()

real_t bdm::Random::PoissonD ( real_t  mean)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 83 of file random.cc.

◆ SetGenerator()

void bdm::Random::SetGenerator ( TRandom *  new_rng)

Updates the internal random number generator

See also
https://root.cern/doc/master/classTRandom.html for a list of available choices

Definition at line 124 of file random.cc.

◆ SetSeed()

void bdm::Random::SetSeed ( uint64_t  seed)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 118 of file random.cc.

◆ Sphere()

MathArray< real_t, 3 > bdm::Random::Sphere ( real_t  radius)

Forwards call to ROOT's TRandom.

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 110 of file random.cc.

◆ Uniform() [1/2]

real_t bdm::Random::Uniform ( real_t  max = 1.0)

Forwards call to ROOT's TRandom.
Returns a uniform deviate on the interval (0, max).

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 62 of file random.cc.

◆ Uniform() [2/2]

real_t bdm::Random::Uniform ( real_t  min,
real_t  max 
)

Forwards call to ROOT's TRandom.
Returns a uniform deviate on the interval (min, max).

See also
https://root.cern/doc/master/classTRandom.html

Definition at line 65 of file random.cc.

◆ UniformArray() [1/2]

template<uint64_t N>
MathArray<real_t, N> bdm::Random::UniformArray ( real_t  max = 1.0)
inline

Returns an array of uniform random numbers in the interval (0, max)

Definition at line 281 of file random.h.

◆ UniformArray() [2/2]

template<uint64_t N>
MathArray<real_t, N> bdm::Random::UniformArray ( real_t  min,
real_t  max 
)
inline

Returns an array of uniform random numbers in the interval (min, max)

Definition at line 291 of file random.h.

Friends And Related Function Documentation

◆ DistributionRng< int >

friend class DistributionRng< int >
friend

Definition at line 423 of file random.h.

◆ DistributionRng< real_t >

friend class DistributionRng< real_t >
friend

Definition at line 422 of file random.h.

Member Data Documentation

◆ generator_

TRandom* bdm::Random::generator_ = nullptr
private

Definition at line 425 of file random.h.

◆ udd_tf1_map_

std::unordered_map<UserDefinedDist, TF1*> bdm::Random::udd_tf1_map_
private

Stores TF1 pointers that have been created for a specific user-defined 1D distribution

Definition at line 428 of file random.h.

◆ udd_tf2_map_

std::unordered_map<UserDefinedDist, TF2*> bdm::Random::udd_tf2_map_
private

Stores TF2 pointers that have been created for a specific user-defined 2D distribution

Definition at line 431 of file random.h.

◆ udd_tf3_map_

std::unordered_map<UserDefinedDist, TF3*> bdm::Random::udd_tf3_map_
private

Stores TF3 pointers that have been created for a specific user-defined 3D distribution

Definition at line 434 of file random.h.


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