#gaussian #curve-fitting #gaussian-curve

gaussian_curve_fit

A no_std and no alloc library for gaussian curve coefficents calculation

7 releases

new 0.3.1 Jan 21, 2025
0.3.0 Jan 21, 2025
0.2.4 Dec 12, 2024
0.2.3 Nov 26, 2024
0.1.1 Nov 2, 2024

#484 in Math

Download history 442/week @ 2024-10-31 50/week @ 2024-11-07 2/week @ 2024-11-14 274/week @ 2024-11-21 30/week @ 2024-11-28 4/week @ 2024-12-05 145/week @ 2024-12-12 1/week @ 2024-12-19 156/week @ 2025-01-16

156 downloads per month

GPL-2.0-or-later

18KB
230 lines

gaussian_curve_fit

Rust

A no_std and no alloc library for gaussian curve coefficents calculation.

example

    let mut gaussian_coes = GaussianCoefficents2D::default();
    let xdata = [
        -8.0f32, -6.0f32, -4.0f32, -2.0f32, 0.0f32, 2.0f32, 4.0f32, 6.0f32,
    ];
    let ydata = [
        6.7f32, 10.6f32, 13.5f32, 15.7f32, 16.6f32, 15.4f32, 14.2f32, 10.3f32,
    ];
    let (x_arr, y_arr) = GaussianCoefficents2D::get_matrix_data_from_8_points(&xdata, &ydata);
    let _ = gaussian_coes.get_coefficents_from_8_matrix_data(&x_arr, &y_arr, 1e-4);

    assert!((gaussian_coes.value(-8.0f32).unwrap_or_default() - 6.7f32).abs() < 1.0f32);
    assert!((gaussian_coes.value(-4.0f32).unwrap_or_default() - 13.5f32).abs() < 1.0f32);
    assert!((gaussian_coes.value(0.0f32).unwrap_or_default() - 16.6f32).abs() < 1.0f32);
    assert!((gaussian_coes.value(4.0f32).unwrap_or_default() - 14.2f32).abs() < 1.0f32);

Dependencies

~4MB
~81K SLoC