[][src]Function fang_oost::get_expectation_single_element_extended

pub fn get_expectation_single_element_extended<'a, 'b: 'a, U>(
    x_min: f64,
    x_max: f64,
    x: f64,
    fn_inv_discrete: &'b [Complex<f64>],
    vk: U
) -> f64 where
    U: Fn(f64, f64, usize) -> f64 + Sync + Send + 'a, 

Returns expectation at point supplied by the user where characteristic function depends on initial starting point.

Remarks

The endpoints of the vector should have a large enough domain for accuracy.
The "type" of the expectation is handled by the vk function. This function is useful for Levy functions since the characteristic function depends on the initial value of x. See fang_oost_option for an example.

Examples

extern crate num_complex;
extern crate fang_oost;
use num_complex::Complex;
let x_min = -20.0;
let x_max = 25.0;
let x = 3.0;
let mu=2.0;
let sigma:f64=5.0;
let num_u=128;
let norm_cf = |u:&Complex<f64>|(u*mu+0.5*u*u*sigma*sigma).exp();
let discrete_cf=fang_oost::get_discrete_cf(num_u, x_min, x_max, &norm_cf);
let result=fang_oost::get_expectation_single_element_extended(
    x_min, x_max, x, &discrete_cf, 
    |u_im, x, k|{
        if k==0{x-x_min} else { ((x-x_min)*u_im).sin()/u_im }
    }
);