These docs are for iminuit version: 2.17.0 compiled with ROOT-v6-25-02-2017-gd0b406db5e
iminuit is a Jupyter-friendly Python interface for the Minuit2 C++ library maintained by CERN’s ROOT team.
Minuit was designed to minimise statistical cost functions, for likelihood and least-squares fits of parametric models to data. It provides the best-fit parameters and error estimates from likelihood profile analysis.
Supported CPython versions: 3.6+
Supported PyPy versions: 3.6+
Supported platforms: Linux, OSX and Windows.
The iminuit package comes with additional features:
Builtin cost functions for statistical fits
Binned and unbinned maximum-likelihood
Non-linear regression with (optionally robust) weighted least-squares
Gaussian penalty terms
Cost functions can be combined by adding them:
total_cost = cost_1 + cost_2
Support for SciPy minimisers as alternatives to Minuit’s Migrad algorithm (optional)
Support for Numba accelerated functions (optional)
In a nutshell¶
iminuit is intended to be used with a user-provided negative log-likelihood function or least-squares function. Standard functions are included in
iminuit.cost, so you don’t have to write them yourself. The following example shows how iminuit is used with a dummy least-squares function.
from iminuit import Minuit def cost_function(x, y, z): return (x - 2) ** 2 + (y - 3) ** 2 + (z - 4) ** 2 m = Minuit(cost_function, x=0, y=0, z=0) m.migrad() # run optimiser m.hesse() # run covariance estimator print(m.values) # x: 2, y: 3, z: 4 print(m.errors) # x: 1, y: 1, z: 1
iminuit optionally supports an interactive fitting mode in Jupyter notebooks.
numba_stats provides faster implementations of probability density functions than scipy, and a few specific ones used in particle physics that are not in scipy.
jacobi provides a robust, fast, and accurate calculation of the Jacobi matrix of any transformation function and building a function for generic error propagation.
The current 2.x series has introduced breaking interfaces changes with respect to the 1.x series.
All interface changes are documented in the changelog with recommendations how to upgrade. To keep existing scripts running, pin your major iminuit version to <2, i.e.
pip install 'iminuit<2' installs the 1.x series.