Class G2Process
The G2 stochastic process: the two-factor G2++ process with its state shifted so that the two components sum to the short rate, (z₁, z₂) = (x + φ(t), y), x and y the zero-mean Ornstein-Uhlenbeck factors and φ the deterministic offset that fits the initial curve; without a curve, the two zero-mean processes (φ ≡ 0).
public sealed class G2Process : StochasticProcess
- Inheritance
-
G2Process
- Inherited Members
Remarks
A path generated on it satisfies r(tᵢ) = z₁ᵢ + z₂ᵢ, its expectation φ(tᵢ). The step's conditional correlation,
QuantLib's ρση(1 − e^(−(a+b)Δt))/(a + b) over ½ση√((1 − e^(−2aΔt))(1 − e^(−2bΔt))/(ab)), is written as
ρ·f((a+b)Δt)/√(f(2aΔt)·f(2bΔt)), f(x) = (1 − e^(−x))/x, and held in [−1, 1], ρ itself where a = b; φ's terms as
G2's: a divergence, QuantLib's √(1 − ρ²) of a correlation an ulp past ±1 being NaN at ρ = ±1 with a = b
(Divergences/G2ProcessCorrelationBoundTests.cs), and its terms cancelling at small reversion.
Constructors
G2Process(double, double, double, double, double, YieldTermStructure?)
Initializes a new instance of the G2Process class.
public G2Process(double a, double sigma, double b, double eta, double rho, YieldTermStructure? termStructure = null)
Parameters
adoubleThe first factor's mean reversion.
sigmadoubleThe first factor's volatility, not negative.
bdoubleThe second factor's mean reversion.
etadoubleThe second factor's volatility, not negative.
rhodoubleThe factors' correlation.
termStructureYieldTermStructureThe curve the shift fits; null, QuantLib's empty handle, for none.
Exceptions
- ArgumentOutOfRangeException
sigmaoretais negative or NaN.
Properties
A
Gets the first factor's mean reversion a.
public double A { get; }
Property Value
B
Gets the second factor's mean reversion b.
public double B { get; }
Property Value
Eta
Gets the second factor's volatility η.
public double Eta { get; }
Property Value
Rho
Gets the factors' correlation ρ.
public double Rho { get; }
Property Value
Sigma
Gets the first factor's volatility σ.
public double Sigma { get; }
Property Value
Size
Gets the number of dimensions of the process.
public override int Size { get; }
Property Value
TermStructure
Gets the curve the shift fits, or null for none.
public YieldTermStructure? TermStructure { get; }
Property Value
X0
Gets the first component's initial value: φ(0) on a curve, 0 without one.
public double X0 { get; }
Property Value
Y0
Gets the second component's initial value, 0.
public double Y0 { get; }
Property Value
Methods
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 override 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 override 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 override Vector Drift(double t, Vector x)
Parameters
Returns
- Vector
A new vector.
Exceptions
- ArgumentException
xholds fewer values than the state, where QuantLib reads past its end.
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 state, where QuantLib reads past its end.
InitialValues()
The initial values of the state variables.
public override Vector InitialValues()
Returns
- Vector
A new vector.
Phi(double)
The shift φ(t) = f(t) + ½(σ(1 − e^(−at))/a)² + ½(η(1 − e^(−bt))/b)² + ρ(σ(1 − e^(−at))/a)(η(1 − e^(−bt))/b), f the curve's instantaneous forward.
public double Phi(double t)
Parameters
tdoubleThe time.
Returns
- double
φ(t).
Exceptions
- NanoQLException
The process has no curve.
ShortRate(double, double, double)
The short rate at the state: z₁ + z₂, the state already including φ(t).
public double ShortRate(double t, double z1, double z2)
Parameters
Returns
- double
The short rate.
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 override 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.
- ArgumentException
x0holds fewer values than the state, where QuantLib reads past its end.