Skip to main content

Jupyter-friendly Python frontend for MINUIT2 in C++

Project description

https://scikit-hep.org/assets/images/Scikit--HEP-Project-blue.svg https://img.shields.io/pypi/v/iminuit.svg https://img.shields.io/conda/vn/conda-forge/iminuit.svg https://coveralls.io/repos/github/scikit-hep/iminuit/badge.svg?branch=develop https://readthedocs.org/projects/iminuit/badge/?version=latest https://zenodo.org/badge/DOI/10.5281/zenodo.3949207.svg ascl:2108.024 https://img.shields.io/gitter/room/Scikit-HEP/iminuit https://mybinder.org/badge_logo.svg

iminuit is a Jupyter-friendly Python interface for the Minuit2 C++ library maintained by CERN’s ROOT team.

Minuit was designed to minimize 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.

The iminuit package comes with additional features:

  • Builtin cost functions for statistical fits

    • Binned and unbinned maximum-likelihood

    • Template fits with error propagation

    • Least-squares (optionally robust to outliers)

    • Gaussian penalty terms for parameters

    • Cost functions can be combined by adding them: total_cost = cost_1 + cost_2

    • Visualization of the fit in Jupyter notebooks

  • Support for SciPy minimizers as alternatives to Minuit’s MIGRAD algorithm (optional)

  • Support for Numba accelerated functions (optional)

Dependencies

iminuit is (and always will be) a lean package which only depends on numpy, but additional features are enabled if the following optional packages are installed.

  • matplotlib: Visualization of fitted model for builtin cost functions

  • ipywidgets: Interactive fitting, see example below (also requires matplotlib)

  • scipy: Compute Minos intervals for arbitrary confidence levels

  • unicodeitplus: Render names of model parameters in simple LaTeX as Unicode

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 can be used with a user-provided cost functions in form of a 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 to perform an unbinned maximum likelihood fit.

import numpy as np
from iminuit import Minuit
from iminuit.cost import UnbinnedNLL
from scipy.stats import norm

x = norm.rvs(size=1000, random_state=1)

def pdf(x, mu, sigma):
    return norm.pdf(x, mu, sigma)

# Negative unbinned log-likelihood, you can write your own
cost = UnbinnedNLL(x, pdf)

m = Minuit(cost, mu=0, sigma=1)
m.limits["sigma"] = (0, np.inf)
m.migrad()  # find minimum
m.hesse()   # compute uncertainties
Output of the demo in a Jupyter notebook

Interactive fitting

iminuit optionally supports an interactive fitting mode in Jupyter notebooks.

Animated demo of an interactive fit in a Jupyter notebook

Faster than RooFit

When iminuit is used with cost functions and pdfs that are JIT-compiled with numba (JIT-compiled pdfs are provided by numba_stats ), the fit is up to 10x faster compared to an equivalent fit in the RooFit framework. The gain is particularly large when numba with auto-parallelization is compared to parallel computation in RooFit.

doc/_static/roofit_vs_iminuit+numba.svg

More information about this benchmark is given in the Benchmark section of the documentation.

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.

  • boost-histogram from Scikit-HEP provides fast generalized histograms that you can use with the builtin cost functions.

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

Project details


Release history Release notifications | RSS feed

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.23.0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distributions

iminuit-2.23.0-cp311-cp311-win_amd64.whl (342.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

iminuit-2.23.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (403.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

iminuit-2.23.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (373.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

iminuit-2.23.0-cp311-cp311-macosx_10_9_universal2.whl (653.1 kB view details)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

iminuit-2.23.0-cp310-cp310-win_amd64.whl (340.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

iminuit-2.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (402.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

iminuit-2.23.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (372.1 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

iminuit-2.23.0-cp310-cp310-macosx_10_9_universal2.whl (650.2 kB view details)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

iminuit-2.23.0-cp39-cp39-win_amd64.whl (340.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

iminuit-2.23.0-cp39-cp39-win32.whl (295.8 kB view details)

Uploaded CPython 3.9 Windows x86

iminuit-2.23.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (372.2 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

iminuit-2.23.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (371.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

iminuit-2.23.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (383.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

iminuit-2.23.0-cp39-cp39-macosx_10_9_universal2.whl (650.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

iminuit-2.23.0-cp38-cp38-win_amd64.whl (340.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

iminuit-2.23.0-cp38-cp38-win32.whl (295.7 kB view details)

Uploaded CPython 3.8 Windows x86

iminuit-2.23.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (372.0 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

iminuit-2.23.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (370.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

iminuit-2.23.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (382.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

iminuit-2.23.0-cp38-cp38-macosx_10_9_universal2.whl (650.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file iminuit-2.23.0.tar.gz.

File metadata

  • Download URL: iminuit-2.23.0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for iminuit-2.23.0.tar.gz
Algorithm Hash digest
SHA256 98f1589eb18d4882232ff1556d62e7ca19c91bbab7524ac8b405261a674452a1
MD5 62c034d9e6fbb0528325660415884896
BLAKE2b-256 53cafbf6026f8912dff617c28a188dc9ec01fc5dd956f65665211a18165818fc

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: iminuit-2.23.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 342.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for iminuit-2.23.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a3b37a3fbb5504900698a1af30c939cc6cbe2ab450ff8732b251d7f28b5853a7
MD5 7f2f816f2f4827d0cd19965e300c0601
BLAKE2b-256 16ca92b7a8d46a8a1cec46db434ae20fab74db1d11b64452b8ff91403ea5daaf

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24d777179737063c4862384afa6b0aaac94a3694cf39a8059a56b37062e1b135
MD5 2a4bd4cea041973cf4d1c3eef3032959
BLAKE2b-256 38c08bbac5f921d1c87ac0d50a728ae223775d47364e691c48a099e285373bc2

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 74362b40a503bf95b13574709f3896281d463ca55c6798c7e1d7e1d696480dad
MD5 6f6ef36670442ed855e2f18d2b8f3356
BLAKE2b-256 32c740e8569fa2c74fc9be322b5e45e637d047b1f7fa3ae6db925236003200dc

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 02b563bbb6a5cfa5e060cbc16ce2357b5f5440f460976458d439564235436849
MD5 98a76f146b19caad101174973ff4bf38
BLAKE2b-256 3b8f78e4f7165c9963bdd0e1fb4ece24c87141ca3ba7667ffec6c2580359efec

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: iminuit-2.23.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 340.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for iminuit-2.23.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0008f011d101808a6a1668b9d43d375b497b415e1ade0796b895c8302ea6b155
MD5 5dce05f43bafc87ae69ac4249b377845
BLAKE2b-256 09f5d53ddaae21604127951235af24a7ef57962b676ad9e1caed63f3fd7c9bc8

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb1f8686b6e1213835407f52011a81a5c30d9cd2706feb7f92c973433f399213
MD5 4b72e826461d072fb4d3617c619b54ef
BLAKE2b-256 1eef02581a273f407aea2822b584044a5f03fb3cb70ae18ee9c643d2f1dcfdda

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4a2b457d1612e5554ca6d6bb3dbb53fbc4522474168338a6531c99c16d9d95cb
MD5 cca0543cb5e8f8585e93e352e7fea295
BLAKE2b-256 33b5fe1e1d3deeb47761ca58afacb91db96c2b2f6fc3c5beae975d7dd0cd9f00

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a9d62959841380dea52901e368e943ec1bb0e95808a31279338ecd869fddc9fb
MD5 076ab494a9c5974e12f844fdf8ef73ea
BLAKE2b-256 d8edf75a657d8c640412a4f68ed6cc607a1e9943364065f30652b52c231af2aa

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: iminuit-2.23.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 340.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for iminuit-2.23.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 81c9db0c067895e7917ee7c893a44905ccd7b411c7621bc8507cf742050249a0
MD5 2846f70425f60bfd09ee3fa17e2b34d9
BLAKE2b-256 da0e609550592c4865ffd89977bb84da55444f4ca43707af20e9e1e25a5373f4

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: iminuit-2.23.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 295.8 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for iminuit-2.23.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 7389e0ca8eb75945b2a58350234f7dc783148fb083020179e3d34ada1cf9994e
MD5 169202f3bfb03201a672b07f24f8cded
BLAKE2b-256 d5cf6112cf75254a6284dbe05be43da4046e07c641c691dccae1f094717a479b

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1c39ec504dbb96204143a9da3ed766cd85380963c6673e4936f524af8d715f92
MD5 b9c295fba01494908147d30bcdeadccb
BLAKE2b-256 ff00a8a47f219f0ab21637dab7b69ff5adcc961a1def9d38c8ed081e65eff414

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1602b8bcec9a0629203a2be011c7d843ab273610c9aba6825c322c6cd240d871
MD5 6fc1e74600fd37bc15d89dcc727cc391
BLAKE2b-256 8d4a569a5a0ebf6e9634dec02db8704b0e9fc7eb952940670d079a5bbd7a0ac1

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 19f72143d13e7fe06e4794a4e821b61bb2b2c0ef5f3327fb34ccf9da44151d68
MD5 73c09af5e90c8d96db6afdc559d81b53
BLAKE2b-256 a41fad51f7aad49834ad7fd34b2e8b0cd6625f2a8e5fd2534b94a99283d1a9e9

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0e8c293e94d95b90c57f664ba101404264ec608bf6da700d5ff6a1dc36af8652
MD5 f2d06123dad7f72528e1c1baa2cd4537
BLAKE2b-256 3be870c80b5057145726957a85a063dd2214b926fbbb6d1e2836461492fafe0d

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: iminuit-2.23.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 340.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for iminuit-2.23.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fe4a76e32271227dc9eb9377062b0682c0944d40f04ca3bb3b243ad5568fda2a
MD5 8a83377acca92cd621b96ed2ecf6db4c
BLAKE2b-256 7e5c98a0c6486fb8a3313b88503dfc32e71230c3dd019907171ce818f9b115ba

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: iminuit-2.23.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 295.7 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for iminuit-2.23.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 44a771c4086d8b4a92c6cc4f3dc0d84fb0ab8ae7d8e6d4102f683e36f9e384ce
MD5 b418ccb655f5858b1e36d4cc1646c4d2
BLAKE2b-256 da6dfd96f1db8dc952d167b727156e06835d55dd0a303bfcfc3e7e93731e030c

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0f57b297f7d0243eb1ddb03a5c95c9aa8b346c59de6a952dea78f7a87f676835
MD5 c432bda725e54f9f1fb9a8066d8a96db
BLAKE2b-256 b53544d51ea3412c9116342a6855f2bda28f86cf0a6ed3a793f844810fc2aeaf

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c88b7a989c86b7e456b59651839901553d3019fccfe87413af05f4483c558d6d
MD5 88c76beb801c3b6c4619a8332f86709c
BLAKE2b-256 70f23ba6bf0eb84087726f15554b8ec26424ca001881e4768ac807ae8ba336bd

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 8551be24001b53a5062d12880688c97269504cffbd5009136eb69714421622c1
MD5 8d0b5429db35966c6679b93c28d4e5ee
BLAKE2b-256 28afd1a03fa3e6e119a4cb1b0b7ee2cd5084db46b54b35865febea57837d5cde

See more details on using hashes here.

File details

Details for the file iminuit-2.23.0-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for iminuit-2.23.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c3d03ac23034ac73eb2c8c4e6ee5702ae72bfa5b2bce0b16c89604f69448827d
MD5 1fe51a955c92a71524dd8f6dedee058c
BLAKE2b-256 96267c824757d71223bf940626644edb655ade7788da0d166c1666600e4e1edf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page