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

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< double >
 
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,
double  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()

double bdm::Random::BreitWigner ( double  mean = 0,
double  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< double, 2 > bdm::Random::Circle ( double  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()

double bdm::Random::Exp ( double  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()

double bdm::Random::Gaus ( double  mean = 0.0,
double  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,
double  prob 
)

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

Definition at line 352 of file random.cc.

◆ GetBreitWignerRng()

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

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

Definition at line 224 of file random.cc.

◆ GetExpRng()

ExpRng bdm::Random::GetExpRng ( double  tau)

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

Definition at line 196 of file random.cc.

◆ GetGausRng()

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

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

Definition at line 187 of file random.cc.

◆ GetLandauRng()

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

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

Definition at line 205 of file random.cc.

◆ GetPoissonDRng()

PoissonDRng bdm::Random::GetPoissonDRng ( double  mean)

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

Definition at line 214 of file random.cc.

◆ GetPoissonRng()

PoissonRng bdm::Random::GetPoissonRng ( double  mean)

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

Definition at line 361 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 119 of file random.cc.

◆ GetUniformRng()

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

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

Definition at line 178 of file random.cc.

◆ GetUserDefinedDistRng1D()

UserDefinedDistRng1D bdm::Random::GetUserDefinedDistRng1D ( double(*)(const double *, const double *)  f,
const FixedSizeVector< double, 10 > &  params,
double  min,
double  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 double* x, const double* params) { ... } and must return a double.
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 double* x, const double* 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 double* x, const double* 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 244 of file random.cc.

◆ GetUserDefinedDistRng2D()

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

Definition at line 283 of file random.cc.

◆ GetUserDefinedDistRng3D()

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

Definition at line 327 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()

double bdm::Random::Landau ( double  mean = 0,
double  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 ( double  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()

double bdm::Random::PoissonD ( double  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 122 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 116 of file random.cc.

◆ Sphere()

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

Forwards call to ROOT's TRandom.

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

Definition at line 109 of file random.cc.

◆ Uniform() [1/2]

double bdm::Random::Uniform ( double  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]

double bdm::Random::Uniform ( double  min,
double  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<double, N> bdm::Random::UniformArray ( double  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<double, N> bdm::Random::UniformArray ( double  min,
double  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< double >

friend class DistributionRng< double >
friend

Definition at line 422 of file random.h.

◆ DistributionRng< int >

friend class DistributionRng< int >
friend

Definition at line 423 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: