Function fang_oost::get_expectation_extended_move[][src]

pub fn get_expectation_extended_move<'a, 'b: 'a, S, U>(
    x_min: f64,
    x_max: f64,
    x_domain_iterator: S,
    discrete_cf: Vec<Complex<f64>>,
    vk: U
) -> impl IndexedParallelIterator<Item = GraphElement> + 'a where
    S: IndexedParallelIterator<Item = f64> + Sync + 'b,
    U: Fn(f64, f64, usize) -> f64 + Sync + Send + 'b, 
Expand description

Returns expectation over equal mesh in the real domain where characteristic function depends on initial starting point of a Levy process and consumes the discrete_cf vector. Useful when only need to use the discrete_cf once.

Remarks

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. By “moving” the discrete_cf vector we don’t have to “collect” the results until later, potentially making consumption of this module more efficient.

Examples

extern crate num_complex;
extern crate fang_oost;
use num_complex::Complex;
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 x_domain=fang_oost::get_x_domain(num_x, x_min, x_max);
let discrete_cf=fang_oost::get_discrete_cf(num_u, x_min, x_max, &norm_cf);
let result:Vec<fang_oost::GraphElement>=fang_oost::get_expectation_extended_move(
    x_min,
    x_max,
    x_domain,
    discrete_cf,
    |u_im, x, k|{
        if k==0{x-x_min} else { ((x-x_min)*u_im).sin()/u_im }
    }
).collect();