pub struct QuadraticRoughHestonKernel { /* private fields */ }Expand description
The factor weights and discounts of the geometric partition of the fractional kernel.
With eta_i = x^(i - n/2) for i = 1..=n, the measure
mu(dg) = g^(-alpha) dg / (Gamma(alpha) Gamma(1 - alpha)) is lumped on each
[eta_(i-1), eta_i] into one atom, whose mass is the weight and whose mean is the
discount:
c_i = x^((1-alpha)(i-n/2)) (1 - x^(alpha-1)) / ((1-alpha) Gamma(alpha) Gamma(1-alpha))
gamma_i = (1-alpha) x^(i-1-n/2) (x^(2-alpha) - 1) / ((2-alpha) (x^(1-alpha) - 1))value_at is K^n(t) = sum c_i exp(-gamma_i t), which approximates
K(t) = t^(alpha-1) / Gamma(alpha) on a range of t set by n and x. The ratio that
suits a given n is the caller’s choice: there is no default.
Implementations§
Source§impl QuadraticRoughHestonKernel
impl QuadraticRoughHestonKernel
Sourcepub fn try_new(
alpha: Decimal,
factors: usize,
ratio: Decimal,
) -> Result<Self, QuadraticRoughHestonError>
pub fn try_new( alpha: Decimal, factors: usize, ratio: Decimal, ) -> Result<Self, QuadraticRoughHestonError>
Builds the kernel of factors factors from alpha and the geometric ratio.
§Errors
QuadraticRoughHestonError::AlphaOutOfRangewhenalphais outside(1/2, 1).QuadraticRoughHestonError::NoFactorswhenfactorsis zero.QuadraticRoughHestonError::RatioNotAboveOnewhenratiois at most one.QuadraticRoughHestonError::KernelOutOfRangewhen a weight or a discount has no positive value in aDecimal.QuadraticRoughHestonError::BufferTooLargewhenfactorscannot be allocated.QuadraticRoughHestonError::Decimalwhen an input has nof64value.
Sourcepub fn discounts(&self) -> &[Decimal]
pub fn discounts(&self) -> &[Decimal]
The discounts gamma_i, per year, from i = 1 to n, rounded to a Decimal.
Sourcepub fn value_at(
&self,
t: Positive,
) -> Result<Decimal, QuadraticRoughHestonError>
pub fn value_at( &self, t: Positive, ) -> Result<Decimal, QuadraticRoughHestonError>
The approximated kernel K^n(t) = sum c_i exp(-gamma_i t) at t years.
§Errors
Returns QuadraticRoughHestonError::Decimal when t has no f64 value or the
result does not fit a Decimal.
Trait Implementations§
Source§impl Clone for QuadraticRoughHestonKernel
impl Clone for QuadraticRoughHestonKernel
Source§impl Debug for QuadraticRoughHestonKernel
impl Debug for QuadraticRoughHestonKernel
impl StructuralPartialEq for QuadraticRoughHestonKernel
Auto Trait Implementations§
impl Forget for QuadraticRoughHestonKernel
impl Freeze for QuadraticRoughHestonKernel
impl RefUnwindSafe for QuadraticRoughHestonKernel
impl Send for QuadraticRoughHestonKernel
impl Sync for QuadraticRoughHestonKernel
impl Unpin for QuadraticRoughHestonKernel
impl UnsafeUnpin for QuadraticRoughHestonKernel
impl UnwindSafe for QuadraticRoughHestonKernel
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.