Skip to main content

Simple data fitting package

Project description

Pyfit

pip install ifitpy

This fit package permits to, well, fit a given x,y data. It encapsulates both iminuit and curve_fit. There are two type of functions. Simple (linear, expo) and Complex(gaussian, gaussian2d, poly). For Simple function fit(x,y) are fit(x,y,p0) are valid inputs. In the first option the fit attempts to estimate the initial starting point. In the second option, a list of parameters (p0) is used to initialized the fit.

For Complex functions fit(x,y, n) are fit(x,y,p0) are valid inputs. If n is used, then the algorithm will use this value to generate the fitting function with n components. For example, fit(xx,yy,n=3) will fit a sum of two gaussian(2d) or a 3-degree polonimal function. And p0 zero is also estimated. If fit(x,y,n,p0) is used, then p0 will be the initialization parameters. Note that len(p0) = n*parameters_to_fit.

There's also a f.fitBinned(xx,yy,bins=50) option which allows fitting a profile histogram instead of the raw data. This option is often faster and is the recommended one as it takes into account the statistical fluctuation of the data. Don't forget to check the Tutorial notebook.

To extract the fit results use

from ifitpy import Fitter
f = Fitter("linear") #linear, expo, gaussian, gaussian2d, poly
f.fit([0,10], [0,-10])
p = f.getParams()
print(p) # prints a string with the available variables.
print(p.vars) # list of the results
print(p.m) # slope for the “linear” type
print(p.b) # slope for the “intercept” type

This an ongoing project!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ifitpy-0.0.6.tar.gz (7.4 kB view details)

Uploaded Source

File details

Details for the file ifitpy-0.0.6.tar.gz.

File metadata

  • Download URL: ifitpy-0.0.6.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for ifitpy-0.0.6.tar.gz
Algorithm Hash digest
SHA256 56fbf57ba0a43d392516e2cd5ada2244e6adff174f0a7efc55068e6e36af5cd0
MD5 41f1f6aed9dd35b0052becd445e54e78
BLAKE2b-256 96f6ad712cd53158b91e82602708b176a3661c7f4c896e7afe78217a5a51aa47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page