pub fn init<'b>(
        model: &'b Func1D,
        y: &'b Array1<f64>,
        sy: &'b Array1<f64>,
        vary_parameter: &'b Array1<bool>,
        lambda: f64,
    ) -> Minimizer<'b> {
        // at initialization
        let initial_parameters = model.parameters.clone();
        let minimizer_ymodel = model.for_parameters(&initial_parameters);

        // calculate number of parameters that are being varied
        let num_varying_params = vary_parameter
            .iter()
            .fold(0, |sum, val| if *val { sum + 1 } else { sum });
        let num_params = initial_parameters.len();
        let num_data = model.domain.len();
        let chi2 = chi2(&y, &minimizer_ymodel, &sy);
        let dof = num_data - num_varying_params;
        let redchi2 = chi2 / (dof as f64);

        // initialize jacobian
        // J is the parameter gradient of f at the current values
        let j = model.parameter_gradient(&initial_parameters, &vary_parameter, &minimizer_ymodel);

        // W = 1 / sy^2, only diagonal is considered
        let weighting_matrix: Array1<f64> = sy.map(|x| 1.0 / x.powi(2));

        Minimizer {
            model: &model,
            y: &y,
            sy: &sy,
            vary_parameter: &vary_parameter,
            weighting_matrix: weighting_matrix,
            minimizer_parameters: initial_parameters,
            minimizer_ymodel: minimizer_ymodel,
            jacobian: j,
            parameter_cov_matrix: Array2::zeros((num_varying_params, num_varying_params)),
            parameter_errors: Array1::zeros(num_params),
            lambda: lambda,
            num_func_evaluation: 0,
            max_iterations: 10 * num_varying_params,
            num_data: num_data,
            num_varying_params: num_varying_params,
            num_params: num_params,
            chi2: chi2,
            dof: dof,
            redchi2: redchi2,
            convergence_message: "",
            epsilon1: 1e-3,
            epsilon2: 1e-3,
            epsilon3: 1e-1,
            epsilon4: 1e-1,
            lambda_UP_fac: 11.0,
            lambda_DOWN_fac: 9.0,
        }
    }
/// Initializes the LM-algorithm. Performs first calculation of model & gradient
Initializes the LM-algorithm. Performs first calculation of model & gradient
Initializes the LM - algorithm . Performs first calculation of model & gradient
pub fn init<'b>(
        model: &'b Func1D,
        y: &'b Array1<f64>,
        sy: &'b Array1<f64>,
        vary_parameter: &'b Array1<bool>,
        lambda: f64,
    ) -> Minimizer<'b> {
        // at initialization
        let initial_parameters = model.parameters.clone();
        let minimizer_ymodel = model.for_parameters(&initial_parameters);
        // calculate number of parameters that are being varied
        let num_varying_params = vary_parameter
            .iter()
            .fold(0, |sum, val| if *val { sum + 1 } else { sum });
        let num_params = initial_parameters.len();
        let num_data = model.domain.len();
        let chi2 = chi2(&y, &minimizer_ymodel, &sy);
        let dof = num_data - num_varying_params;
        let redchi2 = chi2 / (dof as f64);
        // initialize jacobian
        // J is the parameter gradient of f at the current values
        let j = model.parameter_gradient(&initial_parameters, &vary_parameter, &minimizer_ymodel);
        // W = 1 / sy^2, only diagonal is considered
        let weighting_matrix: Array1<f64> = sy.map(|x| 1.0 / x.powi(2));
        Minimizer {
            model: &model,
            y: &y,
            sy: &sy,
            vary_parameter: &vary_parameter,
            weighting_matrix: weighting_matrix,
            minimizer_parameters: initial_parameters,
            minimizer_ymodel: minimizer_ymodel,
            jacobian: j,
            parameter_cov_matrix: Array2::zeros((num_varying_params, num_varying_params)),
            parameter_errors: Array1::zeros(num_params),
            lambda: lambda,
            num_func_evaluation: 0,
            max_iterations: 10 * num_varying_params,
            num_data: num_data,
            num_varying_params: num_varying_params,
            num_params: num_params,
            chi2: chi2,
            dof: dof,
            redchi2: redchi2,
            convergence_message: "",
            epsilon1: 1e-3,
            epsilon2: 1e-3,
            epsilon3: 1e-1,
            epsilon4: 1e-1,
            lambda_UP_fac: 11.0,
            lambda_DOWN_fac: 9.0,
        }
    }
pub fn init < ' b > ( model : & ' b Func1D , y : & ' b Array1 < f64 > , sy : & ' b Array1 < f64 > , vary_parameter : & ' b Array1 < bool > , lambda : f64 , ) -> Minimizer < ' b > { // at initialization let initial_parameters = model . parameters . clone ( ) ; let minimizer_ymodel = model . for_parameters ( & initial_parameters ) ; // calculate number of parameters that are being varied let num_varying_params = vary_parameter . iter ( ) . fold ( 0 , | sum , val | if * val { sum + 1 } else { sum } ) ; let num_params = initial_parameters . len ( ) ; let num_data = model . domain . len ( ) ; let chi2 = chi2 ( & y , & minimizer_ymodel , & sy ) ; let dof = num_data - num_varying_params ; let redchi2 = chi2 / ( dof as f64 ) ; // initialize jacobian // J is the parameter gradient of f at the current values let j = model . parameter_gradient ( & initial_parameters , & vary_parameter , & minimizer_ymodel ) ; // W = 1 / sy^2, only diagonal is considered let weighting_matrix : Array1 < f64 > = sy . map ( | x | 1.0 / x . powi ( 2 ) ) ; Minimizer { model : & model , y : & y , sy : & sy , vary_parameter : & vary_parameter , weighting_matrix : weighting_matrix , minimizer_parameters : initial_parameters , minimizer_ymodel : minimizer_ymodel , jacobian : j , parameter_cov_matrix : Array2 :: zeros ( ( num_varying_params , num_varying_params ) ) , parameter_errors : Array1 :: zeros ( num_params ) , lambda : lambda , num_func_evaluation : 0 , max_iterations : 10 * num_varying_params , num_data : num_data , num_varying_params : num_varying_params , num_params : num_params , chi2 : chi2 , dof : dof , redchi2 : redchi2 , convergence_message : " " , epsilon1 : 1e-3 , epsilon2 : 1e-3 , epsilon3 : 1e-1 , epsilon4 : 1e-1 , lambda_UP_fac : 11.0 , lambda_DOWN_fac : 9.0 , } }
Initializes the LM-algorithm.
Initializes the LM - algorithm .
model
&'b Func1D
y
&'b Array1<f64>
sy
&'b Array1<f64>
vary_parameter
&'b Array1<bool>
lambda
f64
model
&'b Func1D
y
&'b Array1<f64>
sy
&'b Array1<f64>
vary_parameter
&'b Array1<bool>
lambda
f64