{"id":5101,"library":"zfit","title":"zfit: Scalable Pythonic Model Fitting for High Energy Physics","description":"zfit is a modern, scalable Python library for statistical model fitting, primarily designed for High Energy Physics but applicable broadly. It leverages TensorFlow (and optionally JAX) for accelerated computations on CPUs and GPUs, offering a user-friendly API for defining, manipulating, and fitting complex probability density functions. The current version is 0.28.0, with a release cadence of typically a few months between minor versions, often driven by new feature development and backend compatibility updates.","status":"active","version":"0.28.0","language":"en","source_language":"en","source_url":"https://github.com/zfit/zfit","tags":["physics","statistics","fitting","high-energy-physics","tensorflow","jax","bayesian-inference"],"install":[{"cmd":"pip install zfit[tf]","lang":"bash","label":"Recommended installation with TensorFlow backend"},{"cmd":"pip install zfit[jax]","lang":"bash","label":"Installation with JAX backend"},{"cmd":"pip install zfit","lang":"bash","label":"Minimal installation (includes CPU TensorFlow by default)"}],"dependencies":[{"reason":"Primary backend for numerical computation (CPU and GPU). Included by default or with `[tf]` extra.","package":"tensorflow","optional":true},{"reason":"Used in conjunction with TensorFlow for advanced statistical operations.","package":"tensorflow-probability","optional":true},{"reason":"Alternative backend for numerical computation, enabled with `[jax]` extra.","package":"jax","optional":true},{"reason":"Integrated for Bayesian inference diagnostics and visualization in v0.28.0+.","package":"arviz","optional":true}],"imports":[{"symbol":"Parameter","correct":"from zfit import Parameter"},{"symbol":"Space","correct":"from zfit import Space"},{"note":"Commonly aliased for brevity, e.g., zfit.pdf.Gauss","symbol":"pdf","correct":"import zfit.pdf as zpdf"},{"note":"Commonly aliased for brevity, e.g., zfit.data.Data","symbol":"data","correct":"import zfit.data as zdata"},{"note":"Commonly aliased for brevity, e.g., zfit.loss.UnbinnedNLL","symbol":"loss","correct":"import zfit.loss as zloss"},{"note":"Commonly aliased for brevity, e.g., zfit.minimize.Minuit","symbol":"minimize","correct":"import zfit.minimize as zmin"}],"quickstart":{"code":"import zfit\nfrom zfit import z\n\n# Define parameters\nmu = zfit.Parameter('mu', 0.0, -1.0, 1.0)\nsigma = zfit.Parameter('sigma', 1.0, 0.1, 10.0)\n\n# Define the observable space\nobs = zfit.Space('x', limits=(-5, 5))\n\n# Create a Gaussian PDF\ngauss = zfit.pdf.Gauss(mu=mu, sigma=sigma, obs=obs)\n\n# Generate some data\ndata = gauss.sample(n=1000)\n\n# Create a likelihood loss function\nnll = zfit.loss.UnbinnedNLL(model=gauss, data=data)\n\n# Create a minimizer\nminimizer = zfit.minimize.Minuit()\n\n# Perform the fit\nresult = minimizer.minimize(nll)\n\n# Print the fit results\nprint(result.params)","lang":"python","description":"This quickstart demonstrates defining parameters, an observable space, creating a Gaussian Probability Density Function (PDF), generating data from it, setting up an unbinned negative log-likelihood loss, and performing a fit using the Minuit minimizer. It's a fundamental workflow for zfit."},"warnings":[{"fix":"Update calls using `effsize` to `sumw2`.","message":"The `effsize` weight correction parameter was renamed to `sumw2` in certain contexts for asymptotic uncertainty calculations.","severity":"breaking","affected_versions":"0.26.0 and higher"},{"fix":"If exact reproduction of pre-0.27.0 KDE behavior at boundaries is critical, explicitly set `padding=False` when creating KDEs.","message":"The default padding for KDE (Kernel Density Estimation) functions, specifically `KDE1DimExact`, changed from `False` to `0.1`.","severity":"gotcha","affected_versions":"0.27.0 and higher"},{"fix":"Always check the `requires_python` and the specific backend requirements in the release notes or `pyproject.toml`. Use `pip install zfit[tf]` or `zfit[jax]` to ensure compatible backend versions are installed, or manage your environment carefully if pinning specific backend versions.","message":"zfit frequently updates its TensorFlow and TensorFlow-Probability backend requirements. Major version bumps of these dependencies can cause environment conflicts or necessitate upgrades.","severity":"gotcha","affected_versions":"All versions, specifically 0.24.0 (TF ~2.18, TFP ~0.25) and subsequent releases."},{"fix":"Ensure your Python environment is at least 3.10. For the latest features and compatibility, use Python 3.10-3.13.","message":"As of v0.27.0, zfit explicitly requires Python 3.10 or newer. Support for Python 3.13 was added in v0.28.0.","severity":"breaking","affected_versions":"0.27.0 and higher"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}