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

Uploaded Source

Built Distributions

iminuit-2.22.0-cp311-cp311-win_amd64.whl (335.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

iminuit-2.22.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (389.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

iminuit-2.22.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (361.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

iminuit-2.22.0-cp311-cp311-macosx_10_9_universal2.whl (641.7 kB view details)

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

iminuit-2.22.0-cp310-cp310-win_amd64.whl (335.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

iminuit-2.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (389.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

iminuit-2.22.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (361.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

iminuit-2.22.0-cp310-cp310-macosx_10_9_universal2.whl (641.8 kB view details)

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

iminuit-2.22.0-cp39-cp39-win_amd64.whl (335.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

iminuit-2.22.0-cp39-cp39-win32.whl (293.4 kB view details)

Uploaded CPython 3.9 Windows x86

iminuit-2.22.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (362.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

iminuit-2.22.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (360.9 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

iminuit-2.22.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (373.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

iminuit-2.22.0-cp39-cp39-macosx_10_9_universal2.whl (641.9 kB view details)

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

iminuit-2.22.0-cp38-cp38-win_amd64.whl (335.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

iminuit-2.22.0-cp38-cp38-win32.whl (293.4 kB view details)

Uploaded CPython 3.8 Windows x86

iminuit-2.22.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (361.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

iminuit-2.22.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (360.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

iminuit-2.22.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (373.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

iminuit-2.22.0-cp38-cp38-macosx_10_9_universal2.whl (641.8 kB view details)

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

File details

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

File metadata

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

File hashes

Hashes for iminuit-2.22.0.tar.gz
Algorithm Hash digest
SHA256 e0ccc37bad8bc1bd3b9d3fa07d28d4c0407e25a888faa9b559be2d9afbd2d97c
MD5 481db7c4873221ad2e4eef51939fcb75
BLAKE2b-256 119cc472fde7ae390588946ecc1ab44b9d7cd07d05d16b2379c584d017e98df6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for iminuit-2.22.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ed1dab824b92c20cb9ce8d495dbe6c437af4161ced6386fcff43efdae3a5a55a
MD5 460294c1df6a1019dfddcf0bd7cf2e7b
BLAKE2b-256 80ab1d8f59ba12523f8c85510e93c0826a73638fff8c15fc0f72c47420a3f202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2f87fb8da9a019f86d900c8a8cc23458ce0093c6522b6e95c8cffd3969636bf
MD5 36497e12c8c65e9f8eb4c279d9016ab2
BLAKE2b-256 8657381683d8db0e2da9a4059cb7dfea347127f2b21f126dfb2936e38c66ff1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 18cc7cee15c8c63880d1e56a6961ea9884f4ebf6c2b4316a02207706db4f44c3
MD5 2c2e74ac3f2545b68d32243b8caf728d
BLAKE2b-256 84236ced10f59ee4f3cf96bbb13634ee904b08c4310992ba60e5806ec639cbda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 6b5066680528c4ee87ae8f7e762e2a494bdf25d633846f6196d5622523c20873
MD5 6fb0cb56af7f3965d3af73cb673ce7c6
BLAKE2b-256 a8ec76bb23fb8fb127aa48e7e9995198136964b6ea55c3705a34953b3c69117d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for iminuit-2.22.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f68de432a5e8c0ec05991c50947e2b1003077d55a7c1949c3475bd55ad6bb768
MD5 eb598e96bc344042e20041f0e518d648
BLAKE2b-256 a129a6221ca86228d3af18d7a8073648736b4f9ced8e194ed1b1b2a727d9d8ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e8ca52500f163aa3b80792a94078f64b4e2815262511a9f97c1667ba4b407b72
MD5 67d1da77d379a2481636036ec65563a5
BLAKE2b-256 4954029a012735c5062eb9dd5516962d7bf90276545595f85d08e7354d0b3c62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 49323a59ee9a3a501b4732df4fef0c644b5dec32868150357c8122121e434e43
MD5 56f05d8d5b700d1513b9ecd0c10fe18c
BLAKE2b-256 c3af06be17405355e55ad410e9f74120c4bcf0b4ee2352649b546adda59e5878

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 37ba9bc05546fb08b03347bd048d5a201ad312d5729babac7688675f3ffa1897
MD5 9964b104788be067c0b3e3e092540a56
BLAKE2b-256 2857c162ba700e9f68598490c325c3294a8d285209abd32683c307ea06807fdb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for iminuit-2.22.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5e73fcd919b0777abd8fe0d37f3bcb2983c5986f8f937222be036ffe5bb4f9a6
MD5 c900cb03de2eae35405c103dca022543
BLAKE2b-256 ae3c56d0100e35f994ec47326d86baf1a7d9b75f4a00e1ae44200ccb9f71571c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for iminuit-2.22.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 b6aa3ac087e3a1ffa4c92abc7203af689344ff0160f05d0627458273e9fea02b
MD5 083491b564894336560be80614e60109
BLAKE2b-256 338f31da35bd3280fbb910079885c1441e0854d6a84b01fd5f1f7b96ed64b552

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 56cb740d82b1819d4a40b5f02433f50839de8e4f61a5e10d665c774fa7a861fc
MD5 897afae254d7adbfab2d5d45b58124e0
BLAKE2b-256 edd162f110cf75bea3d59ae5ebf52bcec5d67a467c6f032fa09b4d4b88111077

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cfbbb76ce39eec028db9e513733d80f01a56a620c6cdc6d64a6774267a18c894
MD5 cac8dc5dc445239cafe02fb00ee1c9ff
BLAKE2b-256 8ae0b14f958e6409c9533807fccb354d13b30ca3f57fbffa98097fd1c5556ad9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 2b26530aa7ce1aba03450960e3622fb81d68ac9072bacc676f761bcf0de5c75d
MD5 1f8cd7596b6f54febfcad4183bda078b
BLAKE2b-256 c58d517c6b4b774a77215830e77a582783917223561ae891b209fdffbc91ef6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d35eaad97ccb85f88662525dc00418a1a29a586aca6f91fdf3ea6b504fb6e325
MD5 51e2723860442a9e67b9dedb45737349
BLAKE2b-256 5d99ddc4561ccf96a0875be755f475026ae84d9e23afd518385536a93b1fb3c7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for iminuit-2.22.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ece1f48a50c3a59eea1923ebbf4efe320159b9172c8660ab91a2f4daf01f2b5a
MD5 e1dd154c100fbb436c0113c5fe8186a8
BLAKE2b-256 f0d7ae9b8ee43ded83c65c26f12954b79aa369f1f5a3720f7c6cfccee4db5c99

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for iminuit-2.22.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 b26acf8ba3eef0d2ce055ce28b29a2c9e708e88018e4a6566e6f81ddb21639fd
MD5 308101d4fdf24c1c2bfd9a2b4190a9ec
BLAKE2b-256 493313c8b2c9179cd861921af95eacb8f34e9457c8e67d0d458931d666b72e9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 84f9a55aaf3fcd5c331bcb102fff492be085d51623740481ba9c60e280e25db0
MD5 840245ff913d1de3cbe5a3ca4dc4cce4
BLAKE2b-256 c940412339c759f06b0c22f9fa4bdd78ef34713d6808ac457606e7f90c5b79eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4ae663e2597d3d91ca4a34febf1f44b56a657331a31c62991794173ee819ab52
MD5 b019f3934cb15706a430d64eae84fdf7
BLAKE2b-256 e5e0c7839dea85f8f7881ad1f4cc6b003bbcca405a72b00034f0a72c22012da4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 6ba19df13d4f4f2df213bb21f7336b154a05785574b2f752ef82f8ba330de3be
MD5 ab87d6a96161379e9525ea794479d35c
BLAKE2b-256 1be60e752d219da7d039b7923e0c959e7a24eac6af5610602f7f8827a1cf6bd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iminuit-2.22.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 399a2190cb32b3accc9806b49d9e81c660bdade7133fb1f703a8aab43f4effc7
MD5 cd591247ec46495372a2e0c064d5b59e
BLAKE2b-256 64a4b0672c5a8a508f61d15f90e32e283b2e1fdc4d6f3931ef4d333d570f1926

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