pub fn curve_fit<M>(
model: M,
x: &[f64],
y: &[f64],
sigma: Option<&[f64]>,
initial: Vec<f64>,
solver: &LevenbergMarquardt,
) -> Result<CurveFitResult, ErrorsJSL>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).