Skip to main content

Simple data fitting package

Project description

Pyfit

This an ongoing project!

pip install ifitpy

Fitter Package Instructions

1. Creating a Fitter Instance

f = Fitter("linear")  # Available types: "linear", "expo", "gaussian", "gaussian2d", "poly"

This package provides fitting capabilities for given x, y data, encapsulating both iminuit and curve_fit.

Functions are categorized as:

  • Simple: "linear", "expo"
  • Complex: "gaussian", "gaussian2d", "poly"

2. Performing a Fit

Simple Functions (linear, expo)

f.fit(x, y)  # Estimates initial parameters automatically  
f.fit(x, y, p0)  # Uses provided initial parameters (p0)

Complex Functions (gaussian, gaussian2d, poly)

f.fit(x, y, n)  # Fits using `n` components (e.g., a sum of `n` Gaussians or an `n`-degree polynomial)  
f.fit(x, y, p0)  # Uses provided initial parameters  
f.fit(x, y, n, p0)  # Uses both `n` components and provided initialization parameters  

Note: For fit(x, y, n, p0), the length of p0 must be n * parameters_to_fit.

3. Binned Fitting

The fitBinned function allows fitting a profile histogram instead of raw data, which is often faster and accounts for statistical fluctuations.

f.fitBinned(x, y, bins=50)

4. Extracting Fit Results

f.fit([0, 10], [0, -10])
p = f.getParams()

print(p)         # Prints a summary of available variables  
print(p.vars)    # List of fit results  
print(p.m)       # Slope for the "linear" type  
print(p.b)       # Intercept for the "linear" type  

5. Evaluating the Fitted Function

print(f.evaluate([20]))  # Evaluates the function at x = 20 (useful for plotting)

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.8.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ifitpy-0.0.8-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ifitpy-0.0.8.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for ifitpy-0.0.8.tar.gz
Algorithm Hash digest
SHA256 d373093d4369dd69e5dad8848664ef209a5b743165fc0c7bb782b07e3710e368
MD5 d2762444cafd046057c4ccf32e48fb75
BLAKE2b-256 3f48ba274e0738d8868e45cd7fd4823d8e585f60e447a7729697dae1e3360c17

See more details on using hashes here.

File details

Details for the file ifitpy-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: ifitpy-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for ifitpy-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f0890a2a1f484309ee66f6ae939f358309a8322029e222bdc7d617e833e2c728
MD5 f4d911a8f4d5d9e68542f807c8fe1257
BLAKE2b-256 b44430c278f9b5164038eb4db8353b44216b23078e53f93cc69ff2d0511f1990

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