// ========================================================================= // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) // ========================================================================= #include #include // ------------------------------------------------------------------------- cpPluginsBase::RandomNumberSource:: RandomNumberSource( ) : Superclass( ) { } // ------------------------------------------------------------------------- cpPluginsBase::RandomNumberSource:: ~RandomNumberSource( ) { } // ------------------------------------------------------------------------- void cpPluginsBase::RandomNumberSource:: _Configure( ) { this->ConfigureOutValue< TReal >( "Number" ); } // ------------------------------------------------------------------------- void cpPluginsBase::RandomNumberSource:: _GenerateData( ) { // Seed with a real random value, if available std::random_device r; // Choose a random mean between 1 and 6 std::default_random_engine e1( r( ) ); std::uniform_int_distribution< int > uniform_dist( 1, 6 ); int mean = uniform_dist( e1 ); // Generate a normal distribution around that mean std::seed_seq seed2{ r( ), r( ), r( ), r( ), r( ), r( ), r( ), r( ) }; std::mt19937 e2( seed2 ); std::normal_distribution<> normal_dist( mean, 2 ); // Configure a random number as output this->SetOutValue( "Number", normal_dist( e2 ) ); } // eof - $RCSfile$