1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! # Numra Curve Fitting
//!
//! Nonlinear curve fitting, polynomial fitting, and evaluation.
//!
//! This crate provides tools for fitting parametric models to data,
//! built on top of `numra-optim`'s Levenberg-Marquardt solver and
//! `numra-linalg`'s SVD-based least squares.
//!
//! ## Key functions
//!
//! - [`curve_fit()`] - Fit any `y = f(x, params)` model to data
//! - [`curve_fit_weighted()`] - Weighted nonlinear least squares
//! - [`polyfit()`] - Fit polynomial of given degree
//! - [`polyval()`] - Evaluate polynomial at given points
//!
//! ## Example
//!
//! ```rust
//! use numra_fit::{curve_fit, polyfit, polyval};
//!
//! // Fit an exponential decay: y = a * exp(-b * x)
//! let x = vec![0.0, 1.0, 2.0, 3.0, 4.0, 5.0];
//! let y = vec![5.0, 3.03, 1.84, 1.11, 0.67, 0.41];
//!
//! let result = curve_fit(
//! |x: f64, p: &[f64]| p[0] * (-p[1] * x).exp(),
//! &x, &y, &[4.0, 0.3], None,
//! ).unwrap();
//!
//! println!("a = {:.3}, b = {:.3}", result.params[0], result.params[1]);
//! println!("R^2 = {:.6}", result.r_squared);
//! ```
//!
//! Author: Moussa Leblouba
//! Date: 9 February 2026
//! Modified: 2 May 2026
// Allow some clippy lints prevalent in numerical code
pub use ;
pub use FitError;
pub use ;
pub use ;