NeuroLab
DifferentialEquation Class Reference

A stochastic differential equation. More...

Inheritance diagram for DifferentialEquation:

Public Member Functions

 DifferentialEquation (double x0, double dx0, const string &name="", const string &type="Differential Equation")
 starting value More...
 
 DifferentialEquation (Time *time, double x0, double dx0, const string &name="", const string &type="Differential Equation")
 Construct. More...
 
 DifferentialEquation (const string &name="", const string &type="Differential Equation")
 Construct. More...
 
virtual ~DifferentialEquation ()
 Destroy.
 
virtual void prepareNextState ()
 Calculate value for next time step. More...
 
virtual void init (double x0)
 Sets value to a starting value. More...
 
virtual void init ()
 Sets value to starting value.
 
double getStartingValue () const
 Get the starting value.
 
int addTerm (StochasticFunction *integrand, StochasticVariable *integrator)
 Add term. More...
 
void rmTerm (int n)
 Remove term. More...
 
void setTerm (int n, StochasticFunction *integrand, StochasticVariable *integrator)
 Set term. More...
 
int getNTerms () const
 Get number of terms. More...
 
StochasticFunctiongetIntegrand (int n)
 Get integrand part of a term. More...
 
StochasticVariablegetIntegrator (int n)
 Get integrator part of a term. More...
 
virtual string getParameter (const string &name) const
 Get parameter. More...
 
void setParameter (const string &name, const string &value)
 Set parameter. More...
 
bool isIto () const
 Is integration mode Ito?
 
bool isStratonovich () const
 Is integration mode Stratonovich?
 
void setIto ()
 Set integration mode to Ito.
 
void setStratonovich ()
 Set integration mode to Stratonovich.
 
- Public Member Functions inherited from StochasticVariable
 StochasticVariable (class Time *time, const string &name="", const string &type="Stochastic Variable")
 Create.
 
double operator() ()
 Returns the value at the current time step. More...
 
double d ()
 Returns the increment at the current time step. More...
 
- Public Member Functions inherited from StochasticProcess
 StochasticProcess (class Time *time, const string &name="", const string &type="Stochastic")
 Create.
 
virtual ~StochasticProcess ()
 Destroy.
 
virtual void proceedToNextState ()
 Proceed one time step. More...
 
bool isNextStatePrepared ()
 Whether.
 
virtual double getIncrement ()
 Returns the increment. More...
 
virtual double getCurrentValue ()
 Returns the value of the process. More...
 
virtual double getNextValue ()
 Returns the next value of the process. More...
 
virtual void setNextValue (double d)
 Set the next value of the process. More...
 
virtual void setCurrentValue (double d)
 Set the current value of the process. More...
 
void setDescription (string s)
 Set stochastic description.
 
string getDescription ()
 Get the name. More...
 
- Public Member Functions inherited from Parametric
string getType () const
 Type of object.
 
string getName () const
 Name of object.
 
void setName (const string &name)
 Name of object.
 
string getConfiguration () const
 Returns the configuration of the object. More...
 
string getAllParameters () const
 String with all parameter settings.
 
void addParameter (const string &name)
 Add a parameter. More...
 
void rmParameter (const string &name)
 Remove a parameter. More...
 
- Public Member Functions inherited from TimeDependent
 TimeDependent (class Time *time)
 Construct. More...
 
virtual class TimegetTime () const
 Return pointer to the time object.
 
- Public Member Functions inherited from Physical
 Physical ()
 Construct.
 
 Physical (const Physical &)
 Copy.
 
 Physical (string name)
 Construct.
 
 Physical (string name, string unitPrefix, string unitSymbol)
 Construct.
 
 Physical (string name, Unit unit)
 Construct.
 
virtual string getPhysicalDescription ()
 Returns the physical description. More...
 
virtual string getUnitName ()
 Returns the unit name.
 
virtual string getUnitSymbol ()
 Returns the unit name.
 
virtual void setPhysicalDescription (string name)
 Set the name. Same as setDescription(). More...
 
virtual void setUnit (Unit u)
 Set the unit.
 
virtual void setUnitPrefix (int n)
 Set unit prefix. More...
 
virtual Unit getUnit () const
 Retrieve the unit.
 

Public Attributes

void(DifferentialEquation::* eqnMethodPtr )()
 Member pointer to one of the privat fcns.
 

Additional Inherited Members

- Protected Member Functions inherited from Parametric
 Parametric (const string &name, const string &type)
 Create object of type and name.
 
virtual ~Parametric ()
 Destroy object.
 
- Protected Attributes inherited from StochasticProcess
double stochCurrentValue
 the current value
 
double stochNextValue
 the next value (direct future)
 
bool stochNextStateIsPrepared
 whether prepareNextState() was successful
 
string stochDescription
 the name of the quantity
 

Detailed Description

A stochastic differential equation.

Class implementing stochastic differential equations (SDEs). Ito- and Stratonovich integrals can be chosen, integrators and integrands can be added at runtime.

This class implements stochastic differential equations (SDEs) of the form

\[ dX = \sum_i f_i(X) dY_i \]

(using It\^o integrals), or

\[ dX = \sum_i f_i(X) \circ dY_i \]

(using Stratonovich integrals). The sum goes over multiple different functions $f_i$. These should be intepreted as integral equations of the form

\[ X - X_0 = \sum_i \intop f_i(X) dY_i \]

(Ito), or

\[ X - X_0 = \sum_i \intop f_i(X) \circ dY_i \]

(Stratonovich). It\^o mode can be set by calling setIto(), Stratonovich mode can be set by calling setStratonovich(). Which mode is used can be tested by querying isIto() (true if Ito mode) or isStratonovich() (true if Stratonovich integrals are used). At the moment there is only the 0.5-strong-order Euler scheme implemented, but Milstein and Taylor of higher order are planned for the future. See the main page for display of the error made when integrating. Here is a short example of the difference of Ito and Stratonovich integration (the equation is $dX_t = aX_tdt + bX_tdW_t$ or $dX_t = aX_tdt + bX_t\circ dW_t$ with $a=-8.0$ and $b=0.8$.):

The integrands $f_i(X_t)$ are objects of the type Integrand, and the integrators $dY_i$ are objects of the type Integrator. They are stored in arrays of function objects, and their Integrand::operator()(double) or Integrator::operator()() are called each time proceedToNextState() is called. Use dGetValue() (from StochVar) or operator(double) to get the current value of the integral. The function proceedToNextState() must be used to calculate the values of the next time step, the function prepareNextState() must be used to update the object. New integrators and integrands may be added easily by calling nAddIntegrator() or nAddIntegrand().

DifferentialEquation itself is of type Integrator and of type Integrand, so complex cascades of differential equations may be implemented. If you have a complex network of interdependent SDEs, you must first call the proceedToNextState() function of all objects, then the prepareNextState() function of all objects. Otherwise circular dependencies will not get updated correctly.

Constructor & Destructor Documentation

DifferentialEquation::DifferentialEquation ( double  x0,
double  dx0,
const string &  name = "",
const string &  type = "Differential Equation" 
)

starting value

Construct.

Parameters
x0starting value
dx0starting increment
nameobject name
typeobject type
DifferentialEquation::DifferentialEquation ( Time time,
double  x0,
double  dx0,
const string &  name = "",
const string &  type = "Differential Equation" 
)

Construct.

Parameters
timeglobal time object
x0starting value
dx0starting increment
nameobject name
typeobject type
DifferentialEquation::DifferentialEquation ( const string &  name = "",
const string &  type = "Differential Equation" 
)
inline

Construct.

The same as using DifferentialEquation(0.0, 0.0).

Parameters
nameobject name
typeobject type

Member Function Documentation

int DifferentialEquation::addTerm ( StochasticFunction integrand,
StochasticVariable integrator 
)

Add term.

Returns
index of new term
Parameters
integratorintegrand part of term integrator part of term
StochasticFunction* DifferentialEquation::getIntegrand ( int  n)

Get integrand part of a term.

Parameters
nindex of term
StochasticVariable* DifferentialEquation::getIntegrator ( int  n)

Get integrator part of a term.

Parameters
nindex of term
int DifferentialEquation::getNTerms ( ) const
inline

Get number of terms.

Returns
number of terms in differential equation
virtual string DifferentialEquation::getParameter ( const string &  name) const
virtual

Get parameter.

In a derived class, override this to handle every parameter you implement. If a parameter is described using multiple strings separated by space, this indicates a parameter of a parameter.

Parameters
namename of parameter

Reimplemented from Parametric.

virtual void DifferentialEquation::init ( double  x0)
virtual

Sets value to a starting value.

Parameters
x0starting value
virtual void DifferentialEquation::prepareNextState ( )
virtual

Calculate value for next time step.

This just calculates the next value. Nothing is changed before proceedToNextState() is called.

Reimplemented from StochasticProcess.

void DifferentialEquation::rmTerm ( int  n)

Remove term.

Parameters
nindex of term
void DifferentialEquation::setParameter ( const string &  name,
const string &  value 
)
virtual

Set parameter.

In a derived class, override this to handle every parameter you implement. If a parameter is described using multiple strings separated by space, this indicates a parameter of a parameter.

Parameters
namename of parameter
valuevalue of parameter

Reimplemented from Parametric.

void DifferentialEquation::setTerm ( int  n,
StochasticFunction integrand,
StochasticVariable integrator 
)

Set term.

Parameters
nindex of term
integratorintegrand part of term integrator part of term