Skip to content
Snippets Groups Projects
Select Git revision
  • cmake_subprojects
  • develop default
  • Blockage
  • GuidoBasten
  • Anticipation_Model
  • tgf19ts
  • 313-waiting-behaviour
  • tgf19mc
  • wa_testing
  • trajectories
  • 287-waitingarea
  • 320-one-sided-closed-doors
  • kapakrit-anna
  • 311-improve-ff
  • 306-schedule-for-was
  • 294-events
  • 307-temp-close
  • 302-external-files
  • split_files
  • 298-sources
  • 293-statistics-crossings
  • v0.8.4
  • v0.8.3
  • v0.8.2
  • v0.8.1
  • v0.8
  • v0.7
  • v0.6
  • v0.5-alpha
  • v0.5-alpha1
  • v0.4
31 results

randomnumbergenerator.h

Blame
  • user avatar
    Erik Andresen authored
    52d2597b
    History
    randomnumbergenerator.h 952 B
    #ifndef RANDOMNUMBERGENERATOR_H
    #define RANDOMNUMBERGENERATOR_H
    
    #include <random>
    
    class RandomNumberGenerator
    {
    public:
        //Engine and distribution with random seed
        explicit RandomNumberGenerator(){std::random_device rd;
                                         _randomEngine = std::mt19937(rd());
                                         _rdDistribution = std::uniform_real_distribution<double> (0,1);}
        //Engine and distribution with specific seed
        explicit RandomNumberGenerator(int seed):_randomEngine(std::mt19937(seed)),
            _rdDistribution(std::uniform_real_distribution<double> (0,1)){}
    
        double GetRandomRealBetween0and1(){return _rdDistribution(_randomEngine);}
        std::mt19937& GetRandomEngine(){return _randomEngine;}
    
        void SetSeed(int seed){_randomEngine = std::mt19937(seed);}
    
    private:
        std::mt19937 _randomEngine;
        std::uniform_real_distribution<double> _rdDistribution;
    
    
    };
    
    #endif // RANDOMNUMBERGENERATOR_H