Skip to main content

curve_fit

Function curve_fit 

Source
pub fn curve_fit<M>(
    model: M,
    x: &[f64],
    y: &[f64],
    sigma: Option<&[f64]>,
    initial: Vec<f64>,
    solver: &LevenbergMarquardt,
) -> Result<CurveFitResult, ErrorsJSL>
where M: Fn(f64, &[f64]) -> f64,
Expand description

Fits model(x, p) to data (x_i, y_i) by weighted least squares with Levenberg-Marquardt.

With sigma = Some(σ) each residual is divided by its standard deviation and the covariance is (JᵀJ)⁻¹ (absolute uncertainties). With sigma = None the residuals are unweighted and the covariance is scaled by the reduced chi-squared, which estimates the unknown noise level (as SciPy’s curve_fit does by default).