Jupyter-friendly Python frontend for MINUIT2 in C++
Project description
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
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
Interactive fitting
iminuit optionally supports an interactive fitting mode in Jupyter notebooks.
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.
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
Built Distributions
File details
Details for the file iminuit-2.24.0.tar.gz
.
File metadata
- Download URL: iminuit-2.24.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25ab631c3c8e024b1bcc7c96f66338caac54a4a2324d55f1e3ba5617816e44fd |
|
MD5 | 86785c24bbcd84be87b821246b218e22 |
|
BLAKE2b-256 | 5209fa129a555e36ee059d63b841ac3542685330352261d890548283244f7f2a |
File details
Details for the file iminuit-2.24.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 342.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f6ac552d05c0756bdc8cbb47ce819179b87ab95108d5c7f403e0a568b724d56 |
|
MD5 | 466da309f8403faea169fa781db0af5d |
|
BLAKE2b-256 | 009d4b281fa45832312d655be7abadc0e1c59c25116619fa8406642baa898b15 |
File details
Details for the file iminuit-2.24.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 404.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef167c7f0db8eca81a864ab1077a0e291ee1746d682300aa3fac47ec07452b35 |
|
MD5 | 69a8e411be60b977f145d7801ce8b53f |
|
BLAKE2b-256 | b4ed180e8e6e8e317dec3ac4170fceb29d634719754128af785b792aa99039cf |
File details
Details for the file iminuit-2.24.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 374.3 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06b760881948180cdf7597600a499d7a6b9b93972e28bb64baf12599a7dfd295 |
|
MD5 | 36695ac8d1977608856ba7e3b1b6db71 |
|
BLAKE2b-256 | 7538397f1a4ba24d4aa3bf0200ed1e625ad2348eb96a6068870bd1f665e2b8ac |
File details
Details for the file iminuit-2.24.0-cp311-cp311-macosx_10_9_universal2.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 653.6 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c68b08fbbb19a59cf48086626e85636bbd61c5509997d0b21a91595bfdd2273e |
|
MD5 | 4fa565f7374bd470f65d300127f82b1a |
|
BLAKE2b-256 | 5209053e354088e52fc4ff6617ab8a19871d88982a0f7142b9a1aaf8f6622395 |
File details
Details for the file iminuit-2.24.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 341.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff9ad95f9f88424587035f4d655564d3bd2d10f08a9b9ac1d48c79a889b96612 |
|
MD5 | e9f0e1d3c2659e9436928c88853456ff |
|
BLAKE2b-256 | 53990294645adaa3795ec6315098578bf9ccfa49ba4a0048ab4056db1846d7f6 |
File details
Details for the file iminuit-2.24.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 402.8 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dfee6d0a5aff15e8929fee65a4bcedeba708dd1ec0cf33948208fdf27f42487 |
|
MD5 | 2ea40ba97332896de20ca8c996c6537a |
|
BLAKE2b-256 | 87b9287a76b2645ef78a9cd82828fb6d152808cb109b6c2627504ba2a5c10cba |
File details
Details for the file iminuit-2.24.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 372.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76017b14830b98d3da7441a90add0cd844ce634ff5efe2be2af6a3642d866fa3 |
|
MD5 | 14cd74dc91fbfc59cfad7796d258d575 |
|
BLAKE2b-256 | 6b0ac64f210475a0a35796ab2304cbe8c063895dde0866043d6f44ca6726fe11 |
File details
Details for the file iminuit-2.24.0-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 650.8 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1709b5add21ca5d4b16ce45e18f37d17a11c56f2880d13cc32eeb6d1fb68057c |
|
MD5 | 9ccc00a77f326358e811fd7d8c8420bd |
|
BLAKE2b-256 | 4c6477f322a548b8edef88da42722db8399700c4d17a27c1ef02144fb4aa5a9d |
File details
Details for the file iminuit-2.24.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 341.2 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41cc2547fb9f0dee0ef34e9008f135119774f22a091585085c02f85b76f55fa3 |
|
MD5 | 4f7c916e3231eee6c6b4ea922fafc6e2 |
|
BLAKE2b-256 | 64a44654fb9b0868e19f2a83adee346e70ef4517b7d6f58def6fc2845c419263 |
File details
Details for the file iminuit-2.24.0-cp39-cp39-win32.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp39-cp39-win32.whl
- Upload date:
- Size: 296.2 kB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e85859653abb4c107d39540294378677c46c62940c6fea7f274ca6bb615bbb2 |
|
MD5 | 464c6075ca387627a3235d0ced4e4be1 |
|
BLAKE2b-256 | 1680fb425a8bc84d244b3a63aad6310afd64e8471492dbcbe053a6f1643e2792 |
File details
Details for the file iminuit-2.24.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 372.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dbcca9bc510cef84ce35d11dbed96399d38b74807696cfbd0492b87f36a42c4 |
|
MD5 | 793332b94756c275b58f7dbab9076c91 |
|
BLAKE2b-256 | d1ac6385779a1ae8ff744d22196d9a7adb6745b51b8a45aa81ea68ecb23d92a5 |
File details
Details for the file iminuit-2.24.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 371.5 kB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b66b457879c5d3ae9e66a9c9bed7e93157ed337695730dda7a4a64ddc086283 |
|
MD5 | 950f3b89799fa4c319707680e4440dd0 |
|
BLAKE2b-256 | 16c1b85bd59d171836ea7ef3a2a3ddf0cfe4a1e83cfb1e942fe29b3bb5400865 |
File details
Details for the file iminuit-2.24.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
- Upload date:
- Size: 383.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.12+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdfc18812765454b84a1415433960ce499ec5796aa7a66b735dcf474fb04b2e0 |
|
MD5 | 78c524fb634835e14bd328ec3c57d592 |
|
BLAKE2b-256 | 0902a9c82824d5887ef332dddfb9220a6ae804060c3b70f390ceb31252e826db |
File details
Details for the file iminuit-2.24.0-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 650.9 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c3a4eb1eefac4ac1c0bb1e71da8979a8a027dffc7b92b688bc10a151d47a3d2 |
|
MD5 | 427dc7ff008fdeee9fb2c5c6025dd18d |
|
BLAKE2b-256 | 83132c63012b376ebc5b4d87f649988d2c4989d4b7f0be01d0cdecc393a0bc5b |
File details
Details for the file iminuit-2.24.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 341.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c5b84ba20f77831a022ef92cfc21e73961f3fd15b3877aa5e6d71bd9b8b8ce9 |
|
MD5 | 047f18ea0066adf02d4b75621e8050f7 |
|
BLAKE2b-256 | c47e200a4ec71c53dd6eaeb6c3088ac87a558c7925e18302fd8b25cb0d547060 |
File details
Details for the file iminuit-2.24.0-cp38-cp38-win32.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp38-cp38-win32.whl
- Upload date:
- Size: 296.1 kB
- Tags: CPython 3.8, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97b48608886dbc8c6e812593cbbc0caf20c9e912855c6d60d81e2fa00981aee2 |
|
MD5 | 7ba2eea546be04afd6ff40a558cb0d2b |
|
BLAKE2b-256 | b4bed8ed24c3388ee479df3a63a02dacdf1f28426c216c4d73ee2981dda9812f |
File details
Details for the file iminuit-2.24.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 372.6 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42ada0799013837c34efa715732e2c7a9cd42dd6fa7c060de41dc9749b79cec0 |
|
MD5 | 0ab790210c39672e3e99ae777187f7f7 |
|
BLAKE2b-256 | ca358989adf2c9df2ebc547c829e1f30b47e08f78f1e994f67c19ae9cade24c9 |
File details
Details for the file iminuit-2.24.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 371.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6edbfe0f4467336a91baa49a7ccbb93a5e41b051eb2c39909d79166be7daed5 |
|
MD5 | 160b06e5b40adaa596b3304f072bdf7b |
|
BLAKE2b-256 | 6d3eddac55c2abf92e8af75c1d9bf7eee613b7a1c04079b2b4ed9ba4f46b4088 |
File details
Details for the file iminuit-2.24.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
- Upload date:
- Size: 383.3 kB
- Tags: CPython 3.8, manylinux: glibc 2.12+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e13089908675239d1836edb330809220303669284563430ef3c53b44231b9632 |
|
MD5 | d03347a1d179b084bc9e0a346fec8535 |
|
BLAKE2b-256 | 7631347f29e1a8e61c17bd3589e2d8c0d519bfe7f38b4bd0d92606988e8f1f10 |
File details
Details for the file iminuit-2.24.0-cp38-cp38-macosx_10_9_universal2.whl
.
File metadata
- Download URL: iminuit-2.24.0-cp38-cp38-macosx_10_9_universal2.whl
- Upload date:
- Size: 650.9 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f2a850150868b613592e4848aded9345441ce5a64093cd5f8f047a8c2354a56 |
|
MD5 | 5b69ee55f11b11a7a258365a9b2c888c |
|
BLAKE2b-256 | ba2793451bbeaeba5ff14895a6627f37fea7903b92f8b202878147eda1d199c5 |