BioDynaMo
v1.05.120-25dc9790
|
Go to the documentation of this file.
15 #ifndef CORE_UTIL_RANDOM_H_
16 #define CORE_UTIL_RANDOM_H_
18 #include <unordered_map>
32 template <
typename TSample>
52 for (uint64_t i = 0; i < N; i++) {
143 void Draw(
const char* option =
"");
160 void Draw(
const char* option =
"");
178 void Draw(
const char* option =
"");
213 struct hash<
bdm::UserDefinedDist> {
216 h *= 31 *
reinterpret_cast<std::size_t
>(uddist.ud_function);
217 for (
auto el : uddist.parameters) {
218 h *= 31 * std::size_t(el * 1000);
220 h *= 31 * std::size_t(uddist.xmin * 1000);
221 h *= 31 * std::size_t(uddist.xmax * 1000);
222 h *= 31 * std::size_t(uddist.ymin * 1000);
223 h *= 31 * std::size_t(uddist.ymax * 1000);
224 h *= 31 * std::size_t(uddist.zmin * 1000);
225 h *= 31 * std::size_t(uddist.zmax * 1000);
265 explicit Random(TRootIOCtor*);
280 template <u
int64_t N>
283 for (uint64_t i = 0; i < N; i++) {
290 template <u
int64_t N>
293 for (uint64_t i = 0; i < N; i++) {
397 double (*f)(
const double*,
const double*),
399 const char* option =
nullptr);
403 double (*f)(
const double*,
const double*),
405 real_t ymin,
real_t ymax,
const char* option =
nullptr);
409 double (*f)(
const double*,
const double*),
412 const char* option =
nullptr);
440 #endif // CORE_UTIL_RANDOM_H_
real_t SampleImpl(TRandom *rng) override
real_t Gaus(real_t mean=0.0, real_t sigma=1.0)
MathArray< real_t, 3 > Sphere(real_t radius)
int SampleImpl(TRandom *rng) override
~UserDefinedDistRng3D() override
GausRng GetGausRng(real_t mean=0, real_t sigma=1) const
real_t PoissonD(real_t mean)
~UserDefinedDistRng2D() override
UserDefinedDistRng1D(TRootIOCtor *ioctor)
BDM_CLASS_DEF_OVERRIDE(UserDefinedDistRng3D, 1)
BinomialRng(int ntot, real_t prob)
BDM_CLASS_DEF_OVERRIDE(BreitWignerRng, 1)
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)
MathArray< TSample, 3 > Sample3()
MathArray< real_t, 2 > Circle(real_t radius)
BDM_CLASS_DEF_OVERRIDE(BinomialRng, 1)
BreitWignerRng GetBreitWignerRng(real_t mean=0, real_t gamma=1) const
ExpRng GetExpRng(real_t tau) const
real_t BreitWigner(real_t mean=0, real_t gamma=1)
Random & operator=(const Random &other)
MathArray< TSample, N > SampleArray()
BDM_CLASS_DEF_OVERRIDE(PoissonDRng, 1)
bool operator==(const UserDefinedDist &other) const
PoissonDRng GetPoissonDRng(real_t mean) const
BDM_CLASS_DEF_NV(Random, 3)
~UserDefinedDistRng1D() override
BDM_CLASS_DEF(DistributionRng, 1)
std::unordered_map< UserDefinedDist, TF1 * > udd_tf1_map_
real_t Uniform(real_t max=1.0)
BinomialRng GetBinomialRng(int ntot, real_t prob) const
UserDefinedDistRng3D(TRootIOCtor *ioctor)
virtual MathArray< TSample, 2 > Sample2Impl(TRandom *rng)
BreitWignerRng(real_t mean, real_t gamma)
real_t SampleImpl(TRandom *rng) override
unsigned Integer(int max)
void Draw(const char *option="")
int Binomial(int ntot, real_t prob)
virtual TSample SampleImpl(TRandom *rng)=0
void SetGenerator(TRandom *new_rng)
real_t SampleImpl(TRandom *rng) override
virtual MathArray< TSample, 3 > Sample3Impl(TRandom *rng)
MathArray< real_t, N > UniformArray(real_t max=1.0)
Returns an array of uniform random numbers in the interval (0, max)
BDM_CLASS_DEF_OVERRIDE(PoissonRng, 1)
void Draw(const char *option="")
DistributionRng(TRootIOCtor *)
real_t SampleImpl(TRandom *rng) override
real_t Landau(real_t mean=0, real_t sigma=1)
real_t SampleImpl(TRandom *rng) override
void Draw(const char *option="")
BDM_CLASS_DEF_OVERRIDE(UserDefinedDistRng2D, 1)
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)
~BreitWignerRng() override
std::unordered_map< UserDefinedDist, TF2 * > udd_tf2_map_
MathArray< real_t, N > UniformArray(real_t min, real_t max)
Returns an array of uniform random numbers in the interval (min, max)
UserDefinedDistRng1D GetUserDefinedDistRng1D(double(*f)(const double *, const double *), const FixedSizeVector< real_t, 10 > ¶ms, real_t min, real_t max, const char *option=nullptr)
UniformRng GetUniformRng(real_t min=0, real_t max=1) const
real_t SampleImpl(TRandom *rng) override
virtual ~DistributionRng()=default
MathArray< real_t, 2 > Sample2Impl(TRandom *rng) override
double(* ud_function)(const double *, const double *)
Random number generator that generates samples from a distribution.
TSample Sample()
Draws a sample from the distribution.
MathArray< real_t, 3 > Sample3Impl(TRandom *rng) override
PoissonRng GetPoissonRng(real_t mean) const
FixedSizeVector< real_t, 10 > parameters
UserDefinedDistRng2D(TRootIOCtor *ioctor)
BDM_CLASS_DEF_OVERRIDE(LandauRng, 1)
LandauRng GetLandauRng(real_t mean=0, real_t sigma=1) const
GausRng(real_t mean, real_t sigma)
DistributionRng()=default
std::size_t operator()(const bdm::UserDefinedDist &uddist) const noexcept
BDM_CLASS_DEF_OVERRIDE(GausRng, 1)
BDM_CLASS_DEF_OVERRIDE(ExpRng, 1)
LandauRng(real_t mean, real_t sigma)
int SampleImpl(TRandom *rng) override
real_t SampleImpl(TRandom *rng) override
virtual ~GausRng() override
real_t SampleImpl(TRandom *rng) override
void SetSeed(uint64_t seed)
BDM_CLASS_DEF_OVERRIDE(UserDefinedDistRng1D, 1)
std::unordered_map< UserDefinedDist, TF3 * > udd_tf3_map_
MathArray< real_t, 2 > Sample2Impl(TRandom *rng) override
MathArray< TSample, 2 > Sample2()