Class StochasticProcessArray
An array of correlated one-dimensional stochastic processes.
public sealed class StochasticProcessArray : StochasticProcess
- Inheritance
-
StochasticProcessArray
- Inherited Members
Remarks
The correlation's pseudo square root is taken at construction by the spectral salvaging algorithm, as QuantLib's; each process evolves on its row of the correlated increments. The array's time is its first process's.
Constructors
StochasticProcessArray(ImmutableArray<StochasticProcess1D>, Matrix)
Initializes a new instance of the StochasticProcessArray class.
public StochasticProcessArray(ImmutableArray<StochasticProcess1D> processes, Matrix correlation)
Parameters
processesImmutableArray<StochasticProcess1D>The one-dimensional processes.
correlationMatrixTheir correlation matrix, symmetric, of the processes' number.
Exceptions
- ArgumentException
The correlation matrix isn't square or is empty (PseudoSqrt(Matrix, SalvagingAlgorithmType)), there's no process, the matrix's size differs from the processes' number, or a process is null.
Properties
Size
Gets the number of dimensions of the process.
public override int Size { get; }
Property Value
Methods
Apply(Vector, Vector)
The changed state, each process applying its own element's change.
public override Vector Apply(Vector x0, Vector dx)
Parameters
Returns
- Vector
A new vector.
Exceptions
- ArgumentException
x0ordxholds fewer values than the processes, where QuantLib reads past its end.
Correlation()
The correlation the array's square root gives back, S·Sᵀ.
public Matrix Correlation()
Returns
- Matrix
A new matrix.
Covariance(double, Vector, double)
The covariance: the standard deviation times its transpose.
public override Matrix Covariance(double t0, Vector x0, double dt)
Parameters
t0doubleThe start of the interval.
x0VectorThe state at its start, one element per process.
dtdoubleThe interval's length.
Returns
- Matrix
A new matrix.
Exceptions
- ArgumentException
x0holds fewer values than the processes, where QuantLib reads past its end.
Diffusion(double, Vector)
The diffusion: the correlation's square root, each row times its process's diffusion.
public override Matrix Diffusion(double t, Vector x)
Parameters
Returns
- Matrix
A new matrix.
Exceptions
- ArgumentException
xholds fewer values than the processes, where QuantLib reads past its end.
Drift(double, Vector)
The drift part of the equation, μ(t, x_t).
public override Vector Drift(double t, Vector x)
Parameters
Returns
- Vector
A new vector.
Exceptions
- ArgumentException
xholds fewer values than the processes, where QuantLib reads past its end.
Evolve(double, Vector, double, Vector)
The state after a time interval: the increments correlated by the correlation's square root, each process evolved by its own.
public override Vector Evolve(double t0, Vector x0, double dt, Vector dw)
Parameters
t0doubleThe start of the interval.
x0VectorThe state at its start, one element per process.
dtdoubleThe interval's length.
dwVectorThe independent Brownian increments, one per process.
Returns
- Vector
A new vector.
Exceptions
- ArgumentException
x0holds fewer values than the processes, where QuantLib reads past its end.
Evolve(double, ReadOnlySpan<double>, double, ReadOnlySpan<double>, Span<double>)
The state after a time interval, written into the caller's span with nothing allocated: the allocating form's
arithmetic, the correlated increments written row by row into result in the order of the
matrix product, then each process evolved on its own entry in place.
public override 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, one element per process.
dtdoubleThe interval's length.
dwReadOnlySpan<double>The independent Brownian increments, one per process.
resultSpan<double>The state at the interval's end, of the array's size at least; it mustn't overlap
x0ordw.
Exceptions
- ArgumentException
dw's length isn't the correlation's.
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 override 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.
- ArgumentException
x0holds fewer values than the processes, where QuantLib reads past its end.
InitialValues()
The initial values of the state variables.
public override Vector InitialValues()
Returns
- Vector
A new vector.
InitialValues(Span<double>)
The initial values, each process's, written into the caller's span; nothing is allocated.
public override void InitialValues(Span<double> result)
Parameters
Exceptions
- ArgumentException
resultis shorter than the array.
Process(int)
The i-th process.
public StochasticProcess1D Process(int i)
Parameters
iintThe index.
Returns
- StochasticProcess1D
The process.
Exceptions
- ArgumentOutOfRangeException
iisn't one of the processes, where QuantLib reads past its end.
StdDeviation(double, Vector, double)
The standard deviation: the correlation's square root, each row times its process's standard deviation.
public override Matrix StdDeviation(double t0, Vector x0, double dt)
Parameters
t0doubleThe start of the interval.
x0VectorThe state at its start, one element per process.
dtdoubleThe interval's length.
Returns
- Matrix
A new matrix.
Exceptions
- ArgumentException
x0holds fewer values than the processes, where QuantLib reads past its end.
Time(Date)
The time a date denotes: the first process's.
public override double Time(Date date)
Parameters
dateDateThe date.
Returns
- double
The time.
Exceptions
- ArgumentException
dateisdefault(Date).- NanoQLException
The first process doesn't convert dates to times.