aGrUM  0.16.0
utils_random_inl.h
Go to the documentation of this file.
1 
30 // to ease IDE parser
32 namespace gum {
33 
34  INLINE
35  Idx randomValue(const Size max) { return (Idx)(rand() % max); }
36 
37  INLINE
38  double randomProba() { return ((double)rand()) / ((double)RAND_MAX); }
39 
40  INLINE
41  void initRandom(unsigned int seed) {
42  if (seed) {
43  srand(seed);
44  } else {
45  srand(randomGeneratorSeed());
46  }
47  }
48 
49 } /* namespace gum */
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
double randomProba()
Returns a random double between 0 and 1 included (i.e.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
unsigned int randomGeneratorSeed()
Returns the aGrUM's seed used by the std::generators.
void initRandom(unsigned int seed=0)
Initialize random generator seed.
Size Idx
Type for indexes.
Definition: types.h:53
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.