Struct ExponentialSplines
pub struct ExponentialSplines {
reference_date: NaiveDate,
params: Vec<f64>,
}Expand description
An exponential-splines discount curve (the Vasicek-Fong family).
DF(τ) = Σₖ βₖ·e^{−k·α·τ} / Σₖ βₖ, k = 1 … NA basis of decaying exponentials at multiples of one decay rate. N + 1
parameters, stored [β₁ … β_N, ln α].
DF(0) = 1 by construction, and by normalisation rather than by
constraint: every basis function is one at the origin, so dividing by the
coefficient sum makes the value there exactly one whatever the coefficients
are. No parameter is privileged and the solver steps all of them freely.
Unlike the two shapes above, this one does not guarantee positive,
decreasing discount factors — so a fit of it is checked afterwards. See
validity.
Fields§
§reference_date: NaiveDate§params: Vec<f64>[β₁ … β_N, ln α].
Implementations§
§impl ExponentialSplines
impl ExponentialSplines
pub fn new(
reference_date: NaiveDate,
betas: &[f64],
alpha: f64,
) -> Result<Self, CurveError>
pub fn new( reference_date: NaiveDate, betas: &[f64], alpha: f64, ) -> Result<Self, CurveError>
An exponential-splines curve from coefficients and a decay.
§Errors
CurveError::NonFinite for a non-finite parameter, a decay that is
not strictly positive, an empty basis, or coefficients summing to zero
— which the normalisation would divide by.
pub fn reference_date(&self) -> NaiveDate
pub fn reference_date(&self) -> NaiveDate
The curve’s reference date.
pub fn parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
The free parameters, [β₁ … β_N, ln α].
pub fn validity(&self, horizon: NaiveDate) -> Result<(), NaiveDate>
pub fn validity(&self, horizon: NaiveDate) -> Result<(), NaiveDate>
Whether the curve’s discount factors are positive and decreasing across
horizon, sampled monthly.
The form gives no such guarantee, so a fit of it is checked here rather than trusted. Sampling the horizon and not the fitted points is the point: a curve invalid only between its inputs prices most of them acceptably, which is exactly how the failure hides.
§Errors
The first date at which the curve is not a discount curve — where a factor is non-positive, non-finite, or larger than the one before it.
pub fn view<R: Scalar>(&self) -> ExponentialSplinesView<'_, R>
pub fn view<R: Scalar>(&self) -> ExponentialSplinesView<'_, R>
This curve lifted into mode R.
pub(crate) fn view_with_slice<'a, R: Scalar>(
&'a self,
rest: &mut &'a [R],
) -> ExponentialSplinesView<'a, R>
pub(crate) fn view_with_slice<'a, R: Scalar>( &'a self, rest: &mut &'a [R], ) -> ExponentialSplinesView<'a, R>
One step of a substituted walk.
pub(crate) fn view_seeding<R: Scalar + Seedable>(
&self,
seed: &mut Option<usize>,
) -> ExponentialSplinesView<'_, R>
pub(crate) fn view_seeding<R: Scalar + Seedable>( &self, seed: &mut Option<usize>, ) -> ExponentialSplinesView<'_, R>
One step of a seeded walk.
Trait Implementations§
§impl Clone for ExponentialSplines
impl Clone for ExponentialSplines
§fn clone(&self) -> ExponentialSplines
fn clone(&self) -> ExponentialSplines
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ExponentialSplines
impl Debug for ExponentialSplines
§impl PartialEq for ExponentialSplines
impl PartialEq for ExponentialSplines
§fn eq(&self, other: &ExponentialSplines) -> bool
fn eq(&self, other: &ExponentialSplines) -> bool
self and other values to be equal, and is used by ==.