Function fang_oost::get_expectation_x_extended[][src]

pub fn get_expectation_x_extended<T, U>(
    num_x: usize,
    num_u: usize,
    x_min: f64,
    x_max: f64,
    fn_inv: T,
    vk: U
) -> impl IndexedParallelIterator<Item = f64> where
    T: Fn(&Complex<f64>) -> Complex<f64> + Sync + Send,
    U: Fn(f64, f64, usize) -> f64 + Sync + Send

Returns expectation over equal mesh in the real domain where characteristic function depends on initial starting point.

Remarks

The "type" of the expecation 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;
use num_complex::Complex;
extern crate fang_oost;
extern crate rayon;
use rayon::prelude::*;
let mu = 2.0;
let sigma:f64 = 5.0;
let num_u = 256;
let num_x = 1024;
let x_min = -20.0;
let x_max = 25.0;
let norm_cf = |u:&Complex<f64>|(u*mu+0.5*u*u*sigma*sigma).exp();
let result:Vec<f64>=fang_oost::get_expectation_x_extended(
    num_x, num_u, x_min, 
    x_max, &norm_cf, 
    |u, x, k|{
        if k==0{x-x_min} else { ((x-x_min)*u).sin()/u }
    }
).collect();