[][src]Function cf_dist_utils::get_expected_shortfall_and_value_at_risk_discrete_cf

pub fn get_expected_shortfall_and_value_at_risk_discrete_cf(
    alpha: f64,
    x_min: f64,
    x_max: f64,
    max_iterations: usize,
    tolerance: f64,
    discrete_cf: &[Complex<f64>]
) -> Result<RiskMetric, ValueAtRiskError>

Returns expected shortfall (partial expectation) and value at risk (quantile) given a discrete characteristic function.

Remarks

Technically there is no guarantee of convergence for value at risk. The cosine expansion oscillates and the value at risk may be under or over stated. However, in tests it appears to converge for a wide range of distributions

Examples

extern crate num_complex;
use num_complex::Complex;
#[macro_use]
extern crate approx;
extern crate cf_dist_utils;
let mu=2.0;
let sigma=5.0;
let num_u=128;
let x_min=-20.0;
let x_max=25.0;
let alpha=0.05;
let max_iterations=1000;
let tolerance=0.0001;
let norm_cf=vec![Complex::new(1.0, 1.0), Complex::new(-1.0, 1.0)];
let cf_dist_utils::RiskMetric{
    expected_shortfall,
    value_at_risk
}=cf_dist_utils::get_expected_shortfall_and_value_at_risk_discrete_cf(
    alpha, x_min, x_max, max_iterations, tolerance, &norm_cf
).unwrap();