00001 #ifndef GAUSSIANNOISE_H_ 00002 #define GAUSSIANNOISE_H_ 00003 00004 #include "SimObject.h" 00005 #include "ThreadSpecificRandomDistribution.h" 00006 00007 class GaussianNoise : public SimObject 00008 { 00009 SIMOBJECT( GaussianNoise, AdvancePhase::One ) 00010 00011 public: 00012 GaussianNoise( float level = 1.0 ); 00013 virtual ~GaussianNoise(); 00014 00015 virtual double getManagedDelay() const { return 0; } 00016 virtual int nSpikeInputPorts() const { return 0; }; 00017 virtual int nSpikeOutputPorts() const { return 0; }; 00018 virtual int nAnalogInputPorts() const { return 0; }; 00019 virtual int nAnalogOutputPorts() const { return 1; }; 00020 virtual PortType outputPortType(port_t o) const 00021 { 00022 if( o==0) return analog; else return undefined; 00023 }; 00024 virtual PortType inputPortType(port_t i) const 00025 { 00026 return undefined; 00027 }; 00028 00029 virtual double getAnalogOutput(analog_port_id_t port = 0) const; 00030 00031 virtual int reset( double dt ); 00032 virtual int advance( AdvanceInfo const & ); 00033 virtual int non_thread_safe_advance(AdvanceInfo const &); 00034 virtual int plain_boost(AdvanceInfo const &); 00035 virtual int no_action(AdvanceInfo const &); 00036 00038 float level; 00039 00041 double noise; 00042 00043 private: 00045 static ThreadSpecificRandomDistribution< NormalDistribution > noise_gen; 00046 00047 MersenneTwister19937 mt; 00048 NormalDistribution normDist; 00049 00050 boost::mt19937 rng; 00051 boost::normal_distribution<double> nd; 00052 boost::variate_generator< boost::mt19937, boost::normal_distribution<double> > gn; 00053 00054 }; 00055 00056 #endif /*GAUSSIANNOISE_H_*/