Struct ferrilab::CurveFit

source ·
pub struct CurveFit<F: Fn(&f64, &[f64]) -> f64> { /* private fields */ }
Expand description

Object to create a CurveFit with all required parameters.

Implementations§

source§

impl<F: Fn(&f64, &[f64]) -> f64> CurveFit<F>

source

pub fn new( model: F, x_values: impl Into<Vec<f64>>, y_values: impl Into<Vec<f64>> ) -> Self

Constructs a new CurveFit with some default values that can be changed.

source

pub fn initial_point(self, initial_point: impl Into<Vec<f64>>) -> Self

Initial points required for calculating the curve fit.

source

pub fn y_error(self, yerr: Vec<f64>) -> Self

If passed, calculates the weigthed curve fit considaring the y error.

source

pub fn max_iterations(self, max_iterations: impl Into<Option<usize>>) -> Self

In case you want the curve fit algorithm to stop at some point, by default None.

source

pub fn initial_zeros(self, number_of_components: usize) -> Self

Set initial points to zero.

source

pub fn initial_ones(self, number_of_components: usize) -> Self

Set initial points to one.

source

pub fn tolerance(self, tol: impl Into<f64>) -> Self

Custom precision on the curve fit, by default 1e-6.

source

pub fn initial_simplex_scale(self, scale: impl Into<f64>) -> Self

Generates n+1 points using the initial one for calculating the curve fit, by default 0.5. If the scale is a lot smaller than the expected value of the coeficients it may result in errors in the fit.

source

pub fn fit(&self) -> Vec<Measure>

Takes the arbitrary function and aproximates to the curve using every parameter established.

source

pub fn r_value(&self) -> f64

Trait Implementations§

source§

impl<F: Clone + Fn(&f64, &[f64]) -> f64> Clone for CurveFit<F>

source§

fn clone(&self) -> CurveFit<F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F: Debug + Fn(&f64, &[f64]) -> f64> Debug for CurveFit<F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for CurveFit<F>
where F: RefUnwindSafe,

§

impl<F> Send for CurveFit<F>
where F: Send,

§

impl<F> Sync for CurveFit<F>
where F: Sync,

§

impl<F> Unpin for CurveFit<F>
where F: Unpin,

§

impl<F> UnwindSafe for CurveFit<F>
where F: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Ungil for T
where T: Send,