11#define CaAlgoRandom_h 1
66 template<typename T, std::enable_if_t<std::is_floating_point<T>::value,
bool> =
true>
67 T
BoundedGaus(
const T& mean,
const T& sigma,
const T& nSigmas)
const;
73 template<typename T, std::enable_if_t<std::is_floating_point<T>::value,
bool> =
true>
74 T
Uniform(
const T& mean,
const T& sigma)
const;
89 template<typename T, std::enable_if_t<std::is_floating_point<T>::value,
bool>>
92 LOG_IF(fatal, !(nSigmas > 0 && std::isfinite(nSigmas))) <<
"ca::algo::Random::BoundedGaus nSigmas = " << nSigmas;
93 LOG_IF(fatal, !(sigma > 0 && std::isfinite(sigma))) <<
"ca::algo::Random::BoundedGaus sigma = " << sigma;
95 std::normal_distribution rndGaus{mean, sigma};
99 }
while (std::fabs(res - mean) > nSigmas * sigma);
105 template<typename T, std::enable_if_t<std::is_floating_point<T>::value,
bool>>
108 LOG_IF(fatal, !(sigma > 0 && std::isfinite(sigma)))
109 <<
"ca::algo::Random::Uniform sigma = " << sigma <<
" is illegal";
110 std::uniform_real_distribution rnd{-sigma * std::sqrt(3) + mean, sigma * std::sqrt(3) + mean};
A class, providing ROOT-free access to randomly generated variables.
Random & operator=(Random &&)=delete
Move assignment operator.
T Uniform(const T &mean, const T &sigma) const
Returns a random value, addressed with a continuous uniform distribution.
int GetSeed() const
Gets seed of the random generator.
Random(const Random &other)=delete
Copy constructor.
Random & operator=(const Random &)=delete
Copy assignment operator.
GeneratorType_t fGenerator
Random number generator.
T BoundedGaus(const T &mean, const T &sigma, const T &nSigmas) const
Returns a normally distributed random value, limited within a selected sigma range.
unsigned int fSeed
Random number seed.
~Random()=default
Destructor.
Random(Random &&other)=delete
Move constructor.
Random()
Default constructor.
std::mt19937_64 GeneratorType_t
void SetSeed(int seed)
Sets seed to the random generator.
TODO: SZh 8.11.2022: add selection of parameterisation.