Skip to main content
https://zenodo.org/badge/24005390.svg https://coveralls.io/repos/github/tBuLi/symfit/badge.svg?branch=master

Please cite this DOI if symfit benefited your publication. Building this has been a lot of work, and as young researchers your citation means a lot to us. Martin Roelfs & Peter C Kroon, symfit. doi:10.5281/zenodo.1133336

Documentation

http://symfit.readthedocs.org

Project Goals

The goal of this project is simple: to make fitting in Python pythonic. What does pythonic fitting look like? Well, there’s a simple test. If I can give you pieces of example code and don’t have to use any additional words to explain what it does, it’s pythonic.

from symfit import parameters, variables, Fit, Model
import numpy as np

xdata = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
ydata = np.array([2.3, 3.3, 4.1, 5.5, 6.7])
yerr = np.array([0.1, 0.1, 0.1, 0.1, 0.1])

a, b = parameters('a, b')
x, y = variables('x, y')
model = Model({y: a * x + b})

fit = Fit(model, x=xdata, y=ydata, sigma_y=yerr)
fit_result = fit.execute()

Cool right? So now that we have done a fit, how do we use the results?

import matplotlib.pyplot as plt

yfit = model(x=xdata, **fit_result.params)[y]
plt.plot(xdata, yfit)
plt.show()
Linear Fit

Need I say more? How about I let another code example do the talking?

from symfit import parameters, Fit, Equality, GreaterThan

x, y = parameters('x, y')
model = 2 * x * y + 2 * x - x**2 - 2 * y**2
constraints = [
    Equality(x**3, y),
    GreaterThan(y, 1),
]

fit = Fit(- model, constraints=constraints)
fit_result = fit.execute()

I know what you are thinking. “What if I need to fit to a system of Ordinary Differential Equations?”

from symfit import variables, Parameter, ODEModel, Fit, D
import numpy as np

tdata = np.array([10, 26, 44, 70, 120])
adata = 10e-4 * np.array([44, 34, 27, 20, 14])

a, b, t = variables('a, b, t')
k = Parameter('k', 0.1)

model_dict = {
    D(a, t): - k * a**2,
    D(b, t): k * a**2,
}

ode_model = ODEModel(model_dict, initial={t: 0.0, a: 54 * 10e-4, b: 0.0})

fit = Fit(ode_model, t=tdata, a=adata, b=None)
fit_result = fit.execute()

For more fitting delight, check the docs at http://symfit.readthedocs.org.

Metadata

Release files for symfit 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for symfit 0.5.6
File Size Uploaded
symfit-0.5.6.tar.gz 948.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for symfit 0.5.6
File Interpreter ABI Platform
symfit-0.5.6-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 1.0 MB

Release files / symfit-0.5.6.tar.gz

Download URL symfit-0.5.6.tar.gz
Size 948.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b8c97aa96f7e4a385adf8e22d532712e12be4ef845ec18b817e45efdc69eadf4
BLAKE2b-256 checksum
How to use checksums
128eb14a5c9b4fe083f727a39ea369c0db31fd12d75642b34fcd3e877b5a436b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / symfit-0.5.6-py2.py3-none-any.whl

Download URL symfit-0.5.6-py2.py3-none-any.whl
Size 63.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5fec287e0ee28f5e6fe3fbd362398a7e35b8f3d5a2babd388e9780d00631c00e
BLAKE2b-256 checksum
How to use checksums
0621aadaa4cc36d9d5c9606bb99561503d66144c36cd8bb3e2786ad9e9a591ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.5.6 This release

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

0.2.5

0.2.4

1 release file

0.2.3

1 release file

0.2.2

2 release files

0.2.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page