¶
These docs are for iminuit version: 2.21.3 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)
Documentation¶
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 or gitter.
Lecture by Glen Cowan
In the exercises to his lecture for the KMISchool 2022, Glen Cowan shows how to solve statistical problems in Python with iminuit. You can find the lectures and exercises on the Github page, which covers both frequentist and Bayesian methods.
Glen Cowan is a known for his papers and international lectures on statistics in particle physics, as a member of the Particle Data Group, and as author of the popular book Statistical Data Analysis.
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
Interactive fitting¶
iminuit optionally supports an interactive fitting mode in Jupyter notebooks.

Partner projects¶
boost-histogram from Scikit-HEP provides fast generalized histograms that you can use with the builtin cost functions.
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.
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.