11 releases
0.5.1 | Feb 26, 2024 |
---|---|
0.5.0 | Dec 29, 2022 |
0.4.4 | Dec 29, 2022 |
0.4.2 | Oct 22, 2022 |
0.2.0 | Nov 8, 2019 |
#652 in Math
160 downloads per month
Used in pitch-detector
37KB
638 lines
fitting-rs
Curve fitting library for Rust
Updates
See CHANGELOG.md
License
This project is licensed under the MIT license.
lib.rs
:
This library provides fitting::Gaussian
, which represents gaussian function
Details
Use Gaussian::new
to get struct that represents gaussian function.
use fitting::Gaussian;
let gaussian = Gaussian::new(5., 3., 1.);
let x = 5.;
let y = gaussian.value(x);
assert_eq!(&y, gaussian.a());
Use Gaussian::value
and Gaussian::values
to get value(s) of the function.
use fitting::Gaussian;
let gaussian = Gaussian::new(5., 3., 1.);
let x = 5.;
let y = gaussian.value(x);
assert_eq!(&y, gaussian.a());
Use Gaussian::fit
to fitting arrays to the gaussian function.
use fitting::approx::assert_abs_diff_eq;
use fitting::Gaussian;
use fitting::ndarray::{array, Array, Array1};
let gaussian = Gaussian::new(5., 3., 1.);
let x_vec: Array1<f64> = Array::range(1., 10., 1.);
let y_vec: Array1<f64> = gaussian.values(x_vec.clone());
let estimated = Gaussian::fit(x_vec, y_vec).unwrap();
assert_abs_diff_eq!(gaussian, estimated, epsilon = 1e-9);
Dependencies
~1.7–2.4MB
~48K SLoC