OUGenerator.cpp

Go to the documentation of this file.
00001 #include "OUGenerator.h"
00002 
00003 ThreadSpecificRandomDistribution< NormalDistribution > OUGenerator::white_noise;
00004 
00005 OUGenerator::OUGenerator(double g0, double sig, double tau, double dt)
00006     :g0(g0), sig(sig), tau(tau), dt(dt)         
00007 {
00008                 
00009 }
00010 
00011 
00012 OUGenerator::~OUGenerator()
00013 {
00014 }
00015 
00016 
00017 int OUGenerator::adjust(double dt)
00018 {   
00019     dt=dt;
00020     white_noise.set( NormalDistribution( 0.0, 1.0 ) );    
00021         D = pow(sig,2)*2/tau;
00022     A = sqrt(D*tau/2 * (1-exp(-2*dt/tau)));
00023     C = exp(-dt/tau);    
00024     return 0;
00025 }
00026 
00027 
00028 int OUGenerator::reset(double dt)
00029 {
00030         adjust(dt);
00031     value = g0;
00032     return 0;
00033 }
00034 
00035 
00036 void OUGenerator::advance()
00037 {
00038     value = fabs(g0 + (value-g0)*C + A*white_noise());
00039 }

Generated on Wed Jul 9 16:34:39 2008 for PCSIM by  doxygen 1.5.5