27 #ifndef GRT_RANDOM_HEADER 28 #define GRT_RANDOM_HEADER 32 #include "../Util/GRTVersionInfo.h" 34 #include "../DataStructures/Vector.h" 35 #include "../DataStructures/VectorFloat.h" 36 #include "IndexedDouble.h" 38 #define GRT_USE_CXX11_RANDOM_ALGO 0 54 #if GRT_USE_CXX11_RANDOM_ALGO 57 Random(
unsigned long long seed = 0);
71 bool setSeed(
const unsigned long long seed = 0);
142 Float
getUniform(
const Float &minRange=0.0,
const Float &maxRange=1.0);
160 Float
getGauss(
const Float &mu=0.0,
const Float &sigma=1.0);
194 #if GRT_USE_CXX11_RANDOM_ALGO 195 std::default_random_engine generator;
196 std::uniform_real_distribution< Float > uniformRealDistribution;
197 std::normal_distribution< Float > normalDistribution;
199 inline unsigned long long int64() {
200 u = u * 2862933555777941757LL + 7046029254386353087LL;
201 v ^= v >> 17; v ^= v << 31; v ^= v >> 8;
202 w = 4294957665U*(w & 0xffffffff) + (w >> 32);
203 unsigned long long x = u ^ (u << 21); x ^= x >> 35; x ^= x << 4;
206 inline Float doub() {
return 5.42101086242752217E-20 * int64(); }
207 inline unsigned int int32() {
return (
unsigned int)int64(); }
209 unsigned long long u;
210 unsigned long long v;
211 unsigned long long w;
218 #endif //GRT_RANDOM_HEADER VectorFloat getRandomVectorGauss(UINT numDimensions, Float mu=0.0, Float sigma=1.0)
This file contains the Random class, a useful wrapper for generating cross platform random functions...
Float getGauss(const Float &mu=0.0, const Float &sigma=1.0)
Float getRandomNumberGauss(Float mu=0.0, Float sigma=1.0)
Random(unsigned long long seed=0)
Vector< unsigned int > getRandomSubset(const unsigned int startRange, const unsigned int endRange, const unsigned int subsetSize)
int getRandomNumberWeighted(const Vector< int > &values, const VectorFloat &weights)
bool setSeed(const unsigned long long seed=0)
Float getRandomNumberUniform(Float minRange=0.0, Float maxRange=1.0)
int getRandomNumberInt(int minRange, int maxRange)
VectorFloat getRandomVectorUniform(UINT numDimensions, Float minRange=0.0, Float maxRange=1.0)
Float getUniform(const Float &minRange=0.0, const Float &maxRange=1.0)