BioDynaMo
v1.05.120-25dc9790
|
#include <random.h>
Public Member Functions | |
Random () | |
Random (TRootIOCtor *) | |
Random (const Random &other) | |
~Random () | |
Random & | operator= (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 > ¶ms, real_t min, real_t max, const char *option=nullptr) |
UserDefinedDistRng2D | GetUserDefinedDistRng2D (double(*f)(const double *, const double *), const FixedSizeVector< real_t, 10 > ¶ms, 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 > ¶ms, 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 > |
Decorator for ROOT's TRandom Uses TRandom3 as default random number generator
|
private |
int bdm::Random::Binomial | ( | int | ntot, |
real_t | prob | ||
) |
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
BinomialRng bdm::Random::GetBinomialRng | ( | int | ntot, |
real_t | prob | ||
) | const |
BreitWignerRng bdm::Random::GetBreitWignerRng | ( | real_t | mean = 0 , |
real_t | gamma = 1 |
||
) | const |
PoissonDRng bdm::Random::GetPoissonDRng | ( | real_t | mean | ) | const |
PoissonRng bdm::Random::GetPoissonRng | ( | real_t | mean | ) | const |
uint64_t bdm::Random::GetSeed | ( | ) | const |
Forwards call to ROOT's TRandom
.
UniformRng bdm::Random::GetUniformRng | ( | real_t | min = 0 , |
real_t | max = 1 |
||
) | const |
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.
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.
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 |
||
) |
Random::GetUserDefinedDistRng1D
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 |
||
) |
Random::GetUserDefinedDistRng1D
unsigned bdm::Random::Integer | ( | int | max | ) |
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
int bdm::Random::Poisson | ( | real_t | mean | ) |
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
void bdm::Random::SetGenerator | ( | TRandom * | new_rng | ) |
Updates the internal random number generator
void bdm::Random::SetSeed | ( | uint64_t | seed | ) |
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
Forwards call to ROOT's TRandom
.
Returns a uniform deviate on the interval (0, max).
Forwards call to ROOT's TRandom
.
Returns a uniform deviate on the interval (min, max).
|
friend |
|
friend |
|
private |
|
private |
|
private |