Class StochasticProcess
- Namespace
- NanoQL
- Assembly
- NanoQL.dll
A multi-dimensional stochastic process, governed by dx_t = μ(t, x_t) dt + σ(t, x_t) · dW_t.
public abstract class StochasticProcess
- Inheritance
-
StochasticProcess
- Derived
- Inherited Members
Remarks
An extension point, as in QuantLib: the processes derive from it. A process is a value: its members take vectors and return new vectors and matrices, and never keep one they are given. QuantLib's observer interface is removed.
Expectation(double, Vector, double), StdDeviation(double, Vector, double) and Covariance(double, Vector, double) default to the process's discretization, as QuantLib's do; a process built without one overrides the three, or they refuse.
InitialValues(Span<double>) and Evolve(double, ReadOnlySpan<double>, double, ReadOnlySpan<double>, Span<double>) are the in-place forms the multi-dimensional Monte Carlo loop steps through: each defaults to its allocating form and a copy, so a process that doesn't override them keeps its bits; a process overrides them to step without allocating, by QuantLib's arithmetic.
Constructors
StochasticProcess()
Initializes a new instance of the StochasticProcess class, with no discretization.
protected StochasticProcess()
StochasticProcess(StochasticProcessDiscretization)
Initializes a new instance of the StochasticProcess class with a discretization.
protected StochasticProcess(StochasticProcessDiscretization discretization)
Parameters
discretizationStochasticProcessDiscretizationThe discretization.
Fields
discretization
The discretization of the process over a time interval, or null for none.
protected readonly StochasticProcessDiscretization? discretization
Field Value
Properties
Factors
Gets the number of independent factors of the process; by default, its Size.
public virtual int Factors { get; }
Property Value
Size
Gets the number of dimensions of the process.
public abstract int Size { get; }
Property Value
Methods
Apply(Vector, Vector)
Applies a change to the state; by default x + Δx.
public virtual Vector Apply(Vector x0, Vector dx)
Parameters
Returns
- Vector
A new vector.
Exceptions
- ArgumentException
The sizes differ.
Covariance(double, Vector, double)
The covariance V(x_{t0 + Δt} | x_{t0} = x0) of the process after a time interval Δt; by default, the discretization's covariance.
public virtual Matrix Covariance(double t0, Vector x0, double dt)
Parameters
t0doubleThe start of the interval.
x0VectorThe state at its start.
dtdoubleThe interval's length.
Returns
- Matrix
A new matrix.
Exceptions
- NanoQLException
The process has no discretization.
Diffusion(double, Vector)
The diffusion part of the equation, σ(t, x_t).
public abstract Matrix Diffusion(double t, Vector x)
Parameters
Returns
- Matrix
A new matrix.
Drift(double, Vector)
The drift part of the equation, μ(t, x_t).
public abstract Vector Drift(double t, Vector x)
Parameters
Returns
- Vector
A new vector.
Evolve(double, Vector, double, Vector)
The state after a time interval Δt; by default E(x0, t0, Δt) + S(x0, t0, Δt) · Δw, where E is the expectation and S the standard deviation, applied to the expectation by Apply(Vector, Vector).
public virtual Vector Evolve(double t0, Vector x0, double dt, Vector dw)
Parameters
t0doubleThe start of the interval.
x0VectorThe state at its start.
dtdoubleThe interval's length.
dwVectorThe Brownian increments, one per factor.
Returns
- Vector
A new vector.
Exceptions
- ArgumentException
The sizes don't match.
Evolve(double, ReadOnlySpan<double>, double, ReadOnlySpan<double>, Span<double>)
The state after a time interval Δt, written into the caller's span: the in-place form of Evolve(double, Vector, double, Vector), by default its values, copied.
public virtual void Evolve(double t0, ReadOnlySpan<double> x0, double dt, ReadOnlySpan<double> dw, Span<double> result)
Parameters
t0doubleThe start of the interval.
x0ReadOnlySpan<double>The state at its start, of the process's Size.
dtdoubleThe interval's length.
dwReadOnlySpan<double>The Brownian increments, one per factor.
resultSpan<double>The state at the interval's end, of the process's size at least; it mustn't overlap
x0ordw.
Exceptions
- ArgumentException
The sizes don't match.
Expectation(double, Vector, double)
The expectation E(x_{t0 + Δt} | x_{t0} = x0) of the process after a time interval Δt; by default, the discretization's drift applied to x0 by Apply(Vector, Vector).
public virtual Vector Expectation(double t0, Vector x0, double dt)
Parameters
t0doubleThe start of the interval.
x0VectorThe state at its start.
dtdoubleThe interval's length.
Returns
- Vector
A new vector.
Exceptions
- NanoQLException
The process has no discretization.
InitialValues()
The initial values of the state variables.
public abstract Vector InitialValues()
Returns
- Vector
A new vector.
InitialValues(Span<double>)
The initial values of the state variables, written into the caller's span; by default InitialValues()'s values, copied.
public virtual void InitialValues(Span<double> result)
Parameters
Exceptions
- ArgumentException
resultis shorter than the process's size.
StdDeviation(double, Vector, double)
The standard deviation S(x_{t0 + Δt} | x_{t0} = x0) of the process after a time interval Δt; by default, the discretization's diffusion.
public virtual Matrix StdDeviation(double t0, Vector x0, double dt)
Parameters
t0doubleThe start of the interval.
x0VectorThe state at its start.
dtdoubleThe interval's length.
Returns
- Matrix
A new matrix.
Exceptions
- NanoQLException
The process has no discretization.
Time(Date)
The time corresponding to a date in the process's reference system. A process that needs no such conversion keeps this default, which refuses.
public virtual double Time(Date date)
Parameters
dateDateThe date.
Returns
- double
The time.
Exceptions
- ArgumentException
dateisdefault(Date).- NanoQLException
The process doesn't convert dates to times.