00001 #include "GaussianNoise.h" 00002 00003 ThreadSpecificRandomDistribution< NormalDistribution > GaussianNoise::noise_gen; 00004 00005 GaussianNoise::GaussianNoise( float level ) : 00006 level( level ), 00007 normDist( 0.0, 1.0 ), 00008 nd(0.0, 1.0), 00009 gn( rng, nd ) 00010 {} 00011 00012 GaussianNoise::~GaussianNoise() 00013 {} 00014 00015 double GaussianNoise::getAnalogOutput(analog_port_id_t port) const 00016 { 00017 return noise; 00018 } 00019 00020 int GaussianNoise::reset( double dt ) 00021 { 00022 noise_gen.set( NormalDistribution( 0.0, 1.0 ) ); 00023 noise = noise_gen() * level; 00024 return 0; 00025 } 00026 00027 int GaussianNoise::advance(AdvanceInfo const &) 00028 { 00029 noise = noise_gen() * level; 00030 return 0; 00031 } 00032 00033 int GaussianNoise::non_thread_safe_advance(AdvanceInfo const &) 00034 { 00035 noise = normDist( mt ) * level; 00036 return 0; 00037 } 00038 00039 int GaussianNoise::plain_boost(AdvanceInfo const &) 00040 { 00041 noise = gn() * level; 00042 return 0; 00043 } 00044 00045 int GaussianNoise::no_action(AdvanceInfo const &) 00046 { 00047 noise = 0.0 * level; 00048 return 0; 00049 }