¶
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
Tools for numerical error propagation
iminuit.util.propagate
Support for SciPy minimisers as alternatives to Minuit’s Migrad algorithm (optional)
Support for Numba accelerated functions (optional)
Checkout our large and comprehensive list of tutorials that take you all the way from beginner to power user. For help and how-to questions, please use the discussions on GitHub.
In a nutshell¶
from iminuit import Minuit
def cost_function(x, y, z):
return (x - 2) ** 2 + (y - 3) ** 2 + (z - 4) ** 2
cost_function.errordef = Minuit.LEAST_SQUARES
m = Minuit(cost_function, x=0, y=0, z=0)
m.migrad() # run optimiser
print(m.values) # x: 2, y: 3, z: 4
m.hesse() # run covariance estimator
print(m.errors) # x: 1, y: 1, z: 1
Versions¶
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.
These docs are for iminuit version: 2.10.0 compiled with ROOT-v6-25-01-1694-g187368db19