Skip to main content

Jupyter-friendly Python frontend for MINUIT2 in C++

Project description ascl:2108.024

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)

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

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

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

Partner projects

  • 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iminuit-2.11.2.tar.gz (412.0 kB view hashes)

Uploaded source

Built Distributions

iminuit-2.11.2-cp310-cp310-win_amd64.whl (322.8 kB view hashes)

Uploaded cp310

iminuit-2.11.2-cp39-cp39-win_amd64.whl (312.9 kB view hashes)

Uploaded cp39

iminuit-2.11.2-cp39-cp39-win32.whl (275.8 kB view hashes)

Uploaded cp39

iminuit-2.11.2-cp38-cp38-win_amd64.whl (322.9 kB view hashes)

Uploaded cp38

iminuit-2.11.2-cp38-cp38-win32.whl (275.7 kB view hashes)

Uploaded cp38

iminuit-2.11.2-cp37-cp37m-win_amd64.whl (321.5 kB view hashes)

Uploaded cp37

iminuit-2.11.2-cp37-cp37m-win32.whl (278.2 kB view hashes)

Uploaded cp37

iminuit-2.11.2-cp36-cp36m-win_amd64.whl (321.5 kB view hashes)

Uploaded cp36

iminuit-2.11.2-cp36-cp36m-win32.whl (278.2 kB view hashes)

Uploaded cp36

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page