Getting Started

Installation

Install from pypi with

pip install ionics_fits

or add to your poetry project with

poetry add ionics_fits

Basic usage

 1 import numpy as np
 2 from matplotlib import pyplot as plt
 3
 4 from ionics_fits.models.polynomial import Line
 5 from ionics_fits.normal import NormalFitter
 6
 7 a = 3.2
 8 y0 = -9
 9
10 x = np.linspace(-10, 10)
11 y = a * x + y0
12
13 fit = NormalFitter(x, y, model=Line())
14 print(f"Fitted: y = {fit.values['a']:.3f} * x + {fit.values['y0']:.3f}")
15
16 plt.plot(x, y)
17 plt.plot(*fit.evaluate())
18 plt.show()

This fits a test dataset to a line model. Here we’ve used a NormalFitter which performs maximum-likelihood parameter estimation, assuming normal statistics. This is the go-to fitter that’s suitable in most cases.

For more examples, see the Fitter API documentation.