Function fang_oost::get_expectation_discrete_real [−][src]
pub fn get_expectation_discrete_real<'a, 'b: 'a, T, U>(
num_u: usize,
x: &'b [f64],
fn_inv: T,
vk: U
) -> impl IndexedParallelIterator<Item = f64> + 'a where
T: Fn(&Complex<f64>) -> Complex<f64> + Sync + Send + 'a,
U: Fn(f64, f64, usize) -> f64 + Sync + Send + 'a,
Returns expectation over mesh supplied by the user
Remarks
While "x" can be any vector, the endpoints of the vector should have a large enough domain for accuracy. The elements do not need to be equidistant and accuracy does not depend on the number of elements in the x domain (just the complex domain).
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 x_min = -23.0; let x = vec![x_min, 3.0, 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_discrete_real( num_u, &x, &norm_cf, |u, x, k|{ if k==0{x-x_min} else { ((x-x_min)*u).sin()/u } } ).collect();