NeuroLab
|
A stochastic differential equation. More...
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... | |
StochasticFunction * | getIntegrand (int n) |
Get integrand part of a term. More... | |
StochasticVariable * | getIntegrator (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 Time * | getTime () 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 | |
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
(using It\^o integrals), or
(using Stratonovich integrals). The sum goes over multiple different functions . These should be intepreted as integral equations of the form
(Ito), or
(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 or with and .):
The integrands are objects of the type Integrand, and the integrators 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.
DifferentialEquation::DifferentialEquation | ( | double | x0, |
double | dx0, | ||
const string & | name = "" , |
||
const string & | type = "Differential Equation" |
||
) |
starting value
Construct.
x0 | starting value |
dx0 | starting increment |
name | object name |
type | object type |
DifferentialEquation::DifferentialEquation | ( | Time * | time, |
double | x0, | ||
double | dx0, | ||
const string & | name = "" , |
||
const string & | type = "Differential Equation" |
||
) |
Construct.
time | global time object |
x0 | starting value |
dx0 | starting increment |
name | object name |
type | object type |
|
inline |
Construct.
The same as using DifferentialEquation(0.0, 0.0).
name | object name |
type | object type |
int DifferentialEquation::addTerm | ( | StochasticFunction * | integrand, |
StochasticVariable * | integrator | ||
) |
Add term.
integrator | integrand part of term integrator part of term |
StochasticFunction* DifferentialEquation::getIntegrand | ( | int | n | ) |
Get integrand part of a term.
n | index of term |
StochasticVariable* DifferentialEquation::getIntegrator | ( | int | n | ) |
Get integrator part of a term.
n | index of term |
|
inline |
Get number of terms.
|
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.
name | name of parameter |
Reimplemented from Parametric.
|
virtual |
Sets value to a starting value.
x0 | starting value |
|
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.
n | index of term |
|
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.
name | name of parameter |
value | value of parameter |
Reimplemented from Parametric.
void DifferentialEquation::setTerm | ( | int | n, |
StochasticFunction * | integrand, | ||
StochasticVariable * | integrator | ||
) |
Set term.
n | index of term |
integrator | integrand part of term integrator part of term |