[][src]Function fang_oost_option::option_calibration::obj_fn_cmpl

pub fn obj_fn_cmpl<'a>(
    phi_hat: &[Complex<f64>],
    u_array: &[f64],
    params: &[f64],
    maturity: f64,
    cf_fn: &dyn Fn(&Complex<f64>, f64, &[f64]) -> Complex<f64>
) -> f64

Returns function which computes the mean squared error between the empirical and analytical characteristic functions for a vector of parameters.

Examples

extern crate num_complex;
use num_complex::Complex;
extern crate fang_oost_option;
use fang_oost_option::option_calibration;
//u_array is the values in the complex domain to
//calibrate to (ie, making cf(u_i) and cf_emp(u_i)
//close in mean-square).
let u_array = vec![
    -1.0,
    0.5,
    3.0
];
//same length as u (computed using generate_fo_estimate function)
let phi_hat = vec![
    Complex::new(-1.0, 1.0),
    Complex::new(0.5, 0.5),
    Complex::new(3.0, 1.0)    
];
//Gaussian (0, params[0]) distribution
let cf = |u: &Complex<f64>, maturity:f64, params:&[f64]| (u*u*0.5*params[0].powi(2)).exp();
let params=vec![0.0];
let maturity=1.0;
let mean_square_error = option_calibration::obj_fn_cmpl(
    &phi_hat,
    &u_array,
    &params,
    maturity,
    &cf
);