Trait SurvivalProbability
pub trait SurvivalProbability<R: Scalar> {
// Required methods
fn reference_date(&self) -> NaiveDate;
fn survival_probability(&self, date: NaiveDate) -> Result<R, CurveError>;
fn hazard_rate(&self, date: NaiveDate) -> Result<R, CurveError>;
// Provided methods
fn log_survival(&self, date: NaiveDate) -> Result<R, CurveError> { ... }
fn survival_probability_at_ordinal(
&self,
ordinal: i32,
) -> Result<R, CurveError> { ... }
fn log_survival_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError> { ... }
fn default_probability(&self, date: NaiveDate) -> Result<R, CurveError> { ... }
fn default_density(&self, date: NaiveDate) -> Result<R, CurveError> { ... }
}Expand description
What a credit pricer sees. Two questions, one mode, no AD vocabulary.
default_probability and
default_density are derived rather than required:
they are restatements of the two primitives, and a family that could answer
them differently would be answering a different question.
Required Methods§
fn reference_date(&self) -> NaiveDate
fn reference_date(&self) -> NaiveDate
The date at which the survival probability is 1.
fn survival_probability(&self, date: NaiveDate) -> Result<R, CurveError>
fn survival_probability(&self, date: NaiveDate) -> Result<R, CurveError>
The survival probability S(t) = P(τ > t).
§Errors
CurveError::BeforeReference if date precedes the reference date.
fn hazard_rate(&self, date: NaiveDate) -> Result<R, CurveError>
fn hazard_rate(&self, date: NaiveDate) -> Result<R, CurveError>
The instantaneous hazard rate h(t) = −d/dt ln S(t).
§Errors
CurveError::BeforeReference if date precedes the reference date.
Provided Methods§
fn log_survival(&self, date: NaiveDate) -> Result<R, CurveError>
fn log_survival(&self, date: NaiveDate) -> Result<R, CurveError>
The log survival ln S(t) = −∫h — the composition seam on the credit
side. A shocked curve adds to it and exponentiates once; the families
answer it from what they store rather than ln an exp.
§Errors
CurveError::BeforeReference if date precedes the reference date.
fn survival_probability_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
fn survival_probability_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
The survival probability at the proleptic-Gregorian day number
ordinal — the credit side of
YieldCurve::discount_at_ordinal.
A family whose day count is actual days over a constant answers it by
integer subtraction; the default converts back to a date.
§Errors
CurveError::BeforeReference if ordinal precedes the reference
date’s, exactly as the date query reports it.
fn log_survival_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
fn log_survival_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
The log survival at ordinal; see
survival_probability_at_ordinal.
§Errors
fn default_probability(&self, date: NaiveDate) -> Result<R, CurveError>
fn default_probability(&self, date: NaiveDate) -> Result<R, CurveError>
The default probability P(t) = 1 − S(t).
§Errors
CurveError::BeforeReference if date precedes the reference date.
fn default_density(&self, date: NaiveDate) -> Result<R, CurveError>
fn default_density(&self, date: NaiveDate) -> Result<R, CurveError>
The default density f(t) = h(t)·S(t).
§Errors
CurveError::BeforeReference if date precedes the reference date.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".