pub struct CoxIngersollRoss {
pub kappa: f64,
pub theta: f64,
pub sigma: f64,
pub r0: f64,
/* private fields */
}Expand description
Cox-Ingersoll-Ross (CIR) interest rate model.
SDE: dr = kappa*(theta - r)dt + sigmasqrt(r)*dW
The Feller condition 2kappatheta >= sigma^2 ensures r stays positive. Milstein scheme is used for better accuracy.
Fields§
§kappa: f64Mean reversion speed kappa.
theta: f64Long-run mean theta.
sigma: f64Volatility sigma.
r0: f64Initial rate r(0).
Implementations§
Source§impl CoxIngersollRoss
impl CoxIngersollRoss
Sourcepub fn new(kappa: f64, theta: f64, sigma: f64, r0: f64, seed: u64) -> Self
pub fn new(kappa: f64, theta: f64, sigma: f64, r0: f64, seed: u64) -> Self
Creates a new CIR process.
Sourcepub fn feller_satisfied(&self) -> bool
pub fn feller_satisfied(&self) -> bool
Whether the Feller condition 2kappatheta >= sigma^2 is satisfied.
Sourcepub fn path(&self, t_end: f64, n_steps: usize) -> Vec<f64>
pub fn path(&self, t_end: f64, n_steps: usize) -> Vec<f64>
Simulate path using Milstein scheme.
The reflection r -> |r| is used after each step to guarantee non-negativity.
Sourcepub fn stationary_mean(&self) -> f64
pub fn stationary_mean(&self) -> f64
Stationary mean E[r] = theta.
Sourcepub fn stationary_variance(&self) -> f64
pub fn stationary_variance(&self) -> f64
Stationary variance Var[r] = sigma^2 * theta / (2 * kappa).
Auto Trait Implementations§
impl Freeze for CoxIngersollRoss
impl RefUnwindSafe for CoxIngersollRoss
impl Send for CoxIngersollRoss
impl Sync for CoxIngersollRoss
impl Unpin for CoxIngersollRoss
impl UnsafeUnpin for CoxIngersollRoss
impl UnwindSafe for CoxIngersollRoss
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.