iminuit

Jupyter-friendly Python interface for C++ MINUIT2

https://github.com/scikit-hep/iminuit

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 11 DOI reference(s) in README
  • Academic publication links
    Links to: scholar.google, zenodo.org
  • Committers with academic emails
    4 of 38 committers (10.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.0%) to scientific vocabulary

Keywords

c-plus-plus fitting optimization python scikit-hep

Keywords from Contributors

closember jax hep wx tk qt gtk histogram cls asymptotic-formulas
Last synced: 4 months ago · JSON representation ·

Repository

Jupyter-friendly Python interface for C++ MINUIT2

Basic Info
Statistics
  • Stars: 301
  • Watchers: 15
  • Forks: 83
  • Open Issues: 13
  • Releases: 89
Topics
c-plus-plus fitting optimization python scikit-hep
Created about 13 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing License Citation

README.rst

.. |iminuit| image:: doc/_static/iminuit_logo.svg
   :alt: iminuit

|iminuit|
=========

.. version-marker-do-not-remove

.. image:: https://scikit-hep.org/assets/images/Scikit--HEP-Project-blue.svg
   :target: https://scikit-hep.org
.. image:: https://img.shields.io/pypi/v/iminuit.svg
   :target: https://pypi.org/project/iminuit
.. image:: https://img.shields.io/conda/vn/conda-forge/iminuit.svg
   :target: https://github.com/conda-forge/iminuit-feedstock
.. image:: https://coveralls.io/repos/github/scikit-hep/iminuit/badge.svg?branch=develop
   :target: https://coveralls.io/github/scikit-hep/iminuit?branch=develop
.. image:: https://github.com/scikit-hep/iminuit/actions/workflows/docs.yml/badge.svg?branch=main
   :target: https://scikit-hep.org/iminuit
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3949207.svg
   :target: https://doi.org/10.5281/zenodo.3949207
.. image:: https://img.shields.io/badge/ascl-2108.024-blue.svg?colorB=262255
   :target: https://ascl.net/2108.024
   :alt: ascl:2108.024
.. image:: https://img.shields.io/gitter/room/Scikit-HEP/iminuit
   :target: https://gitter.im/Scikit-HEP/iminuit
.. image:: https://mybinder.org/badge_logo.svg
   :target: https://mybinder.org/v2/gh/scikit-hep/iminuit/develop?filepath=doc%2Ftutorial

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

Minuit was designed to optimize statistical cost functions, for maximum-likelihood and least-squares fits. It provides the best-fit parameters and error estimates from likelihood profile analysis.

The iminuit package brings additional features:

- Builtin cost functions for statistical fits to N-dimensional data

  - Unbinned and binned maximum-likelihood + extended versions
  - `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)

Minimal dependencies
--------------------

``iminuit`` is promised to remain a lean package which only depends on ``numpy``, but additional features are enabled if the following optional packages are installed.

- ``numba``: Cost functions are partially JIT-compiled if ``numba`` is 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.

.. code:: python

    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

.. image:: doc/_static/demo_output.png
    :alt: Output of the demo in a Jupyter notebook

Interactive fitting
-------------------

``iminuit`` optionally supports an interactive fitting mode in Jupyter notebooks.

.. image:: doc/_static/interactive_demo.gif
   :alt: Animated demo of an interactive fit in a Jupyter notebook

High performance when combined with numba
-----------------------------------------

When ``iminuit`` is used with cost functions that are JIT-compiled with `numba`_ (JIT-compiled pdfs are provided by `numba_stats`_ ), the speed is comparable to `RooFit`_ with the fastest backend. `numba`_ with auto-parallelization is considerably faster than the parallel computation in `RooFit`_.

.. image:: doc/_static/roofit_vs_iminuit+numba.svg

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

Citation
--------

If you use iminuit in a scientific work, please cite us. A generic BibTeX entry is::

    @article{iminuit,
      author={Hans Dembinski and Piti Ongmongkolkul et al.},
      title={scikit-hep/iminuit},
      DOI={10.5281/zenodo.3949207},
      publisher={Zenodo},
      year={2020},
      month={Dec},
      url={https://doi.org/10.5281/zenodo.3949207}
    }

The DOI and URL in this entry point always to the latest release of iminuit. You can also cite the actual release that you used, please follow the `Zenodo link `_, which offers entries for common bibliography formats for all iminuit releases.

The recommended scientific reference for the MINUIT algorithms is::

    @article{James:1975dr,
        author = "James, F. and Roos, M.",
        title = "{Minuit: A System for Function Minimization and Analysis of the Parameter Errors and Correlations}",
        reportNumber = "CERN-DD-75-20",
        doi = "10.1016/0010-4655(75)90039-9",
        journal = "Comput. Phys. Commun.",
        volume = "10",
        pages = "343--367",
        year = "1975"
    }

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 2.x series has introduced breaking interfaces changes with respect to the 1.x series. There are no plans to introduce further breaking changes.

All interface changes from 1.x to 2.x are documented in the `changelog`_ with recommendations how to upgrade. To keep old scripts running, pin your major iminuit version to <2: the command ``pip install 'iminuit<2'`` installs the 1.x series.

.. _changelog: https://scikit-hep.org/iminuit/changelog.html
.. _tutorials: https://scikit-hep.org/iminuit/tutorials.html
.. _discussions: https://github.com/scikit-hep/iminuit/discussions
.. _gitter: https://gitter.im/Scikit-HEP/iminuit
.. _jacobi: https://github.com/hdembinski/jacobi
.. _numba_stats: https://github.com/HDembinski/numba-stats
.. _boost-histogram: https://github.com/scikit-hep/boost-histogram
.. _numba: https://numba.pydata.org
.. _RooFit: https://root.cern/manual/roofit/

Owner

  • Name: Scikit-HEP Project
  • Login: scikit-hep
  • Kind: organization
  • Email: scikit-hep-forum@googlegroups.com

A community project for High Energy Physics data analysis in Python

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: scikit-hep/iminuit
message: >-
  If you use this software, please cite it using the
  metadata from this file and the MINUIT paper at
  https://doi.org/10.1016/0010-4655(75)90039-9.

  This software includes source code under other
  licenses, see LICENSE in the repository for details.
type: software
authors:
  - given-names: Hans
    family-names: Dembinski
    email: hans.dembinski@gmail.com
    affiliation: TU Dortmund
    orcid: 'https://orcid.org/0000-0003-3337-3850'
  - given-names: Piti
    family-names: Ongmongkolkul
  - given-names: Christoph
    family-names: Deil
  - given-names: Henry
    family-names: Schreiner
  - given-names: Matthew
    family-names: Feickert
  - given-names: Chris
    family-names: Burr
  - given-names: Jason
    family-names: Watson
  - given-names: Fabian
    family-names: Rost
  - given-names: Alex
    family-names: Pearce
  - given-names: Lukas
    family-names: Geiger
  - given-names: Ahmed
    family-names: Abdelmotteleb
  - given-names: Aman
    family-names: Desai
  - given-names: Bernhard M.
    family-names: Wiedemann
  - given-names: Christoph
    family-names: Gohlke
  - given-names: Jeremy
    family-names: Sanders
  - given-names: Jonas
    family-names: Drotleff
  - given-names: Jonas
    family-names: Eschle
  - given-names: Ludwig
    family-names: Neste
  - given-names: Marco Edward
    family-names: Gorelli
  - given-names: Max
    family-names: Baak
  - given-names: Michael
    family-names: Eliachevitch
  - given-names: Omar
    family-names: Zapata
identifiers:
  - type: doi
    value: 10.5281/zenodo.7695764
repository-code: 'https://github.com/scikit-hep/iminuit'
url: 'https://scikit-hep.org/iminuit/'
abstract: >-
  iminuit is a Jupyter-friendly Python interface for the
  Minuit2 C++ library maintained by CERN's ROOT team.
keywords:
  - Python
  - C++
  - fitting
  - optimization
  - statistics
  - data analysis
  - Scikit-HEP
license: MIT

GitHub Events

Total
  • Create event: 32
  • Release event: 2
  • Issues event: 32
  • Watch event: 16
  • Delete event: 32
  • Issue comment event: 68
  • Push event: 82
  • Pull request review comment event: 65
  • Pull request review event: 64
  • Pull request event: 58
  • Fork event: 7
Last Year
  • Create event: 32
  • Release event: 2
  • Issues event: 32
  • Watch event: 16
  • Delete event: 32
  • Issue comment event: 68
  • Push event: 82
  • Pull request review comment event: 65
  • Pull request review event: 64
  • Pull request event: 58
  • Fork event: 7

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 1,354
  • Total Committers: 38
  • Avg Commits per committer: 35.632
  • Development Distribution Score (DDS): 0.387
Past Year
  • Commits: 87
  • Committers: 10
  • Avg Commits per committer: 8.7
  • Development Distribution Score (DDS): 0.494
Top Committers
Name Email Commits
Hans Dembinski h****i@g****m 830
Piti Ongmongkolkul p****8@g****m 181
Christoph Deil D****h@g****m 138
Henry Schreiner h****r@c****h 52
pre-commit-ci[bot] 6****] 49
David Menéndez Hurtado d****o@s****e 23
dependabot[bot] 4****] 23
Matthew Feickert m****t@c****h 9
Jonas Eschle j****e@c****h 4
Christopher Burr c****3@g****m 4
Andrew g****b@l****o 4
Aman Desai 9****i 3
Jason Watson j****n@d****e 3
Fabian Rost f****t@m****g 3
Lukas Geiger l****4@g****m 2
Alex Pearce a****x@a****e 2
Louis Varriano 1****o 2
Ludwig Neste 3****g 2
Agriya Khetarpal 7****l 1
Jan Wagner j****f@t****e 1
Rudi Rödl r****l@u****e 1
huangyong h****6@i****n 1
AhmedAbdelmotteleb 7****b 1
a****w@q****m 1
odidev o****v@p****m 1
jsaarela1 1****1 1
andriish a****h 1
Stephan Lachnit s****t@d****g 1
Omar Andres Zapata Mesa a****s@g****m 1
Michael Eliachevitch m****h@p****e 1
and 8 more...

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 81
  • Total pull requests: 237
  • Average time to close issues: 2 months
  • Average time to close pull requests: 11 days
  • Total issue authors: 49
  • Total pull request authors: 19
  • Average comments per issue: 2.95
  • Average comments per pull request: 0.96
  • Merged pull requests: 205
  • Bot issues: 0
  • Bot pull requests: 103
Past Year
  • Issues: 20
  • Pull requests: 66
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 14 days
  • Issue authors: 17
  • Pull request authors: 7
  • Average comments per issue: 1.85
  • Average comments per pull request: 0.64
  • Merged pull requests: 49
  • Bot issues: 0
  • Bot pull requests: 45
Top Authors
Issue Authors
  • HDembinski (13)
  • yurivict (7)
  • stephanlachnit (3)
  • lvarriano (3)
  • konosubakonoakua (3)
  • olebole (2)
  • henryiii (2)
  • JaySandesara (2)
  • ikrommyd (2)
  • nega0 (2)
  • Joshuazh (2)
  • 2xB (2)
  • alexander-held (1)
  • GWeberJ (1)
  • mdaeron (1)
Pull Request Authors
  • HDembinski (115)
  • pre-commit-ci[bot] (81)
  • dependabot[bot] (52)
  • henryiii (35)
  • amanmdesai (4)
  • lvarriano (4)
  • matthewfeickert (3)
  • adryyan (3)
  • ikrommyd (2)
  • The-Ludwig (2)
  • Joshuazh (2)
  • agriyakhetarpal (2)
  • meliache (1)
  • jsaarela1 (1)
  • jpwgnr (1)
Top Labels
Issue Labels
enhancement (5) good first issue (4) PyHEP 2022 Hackashop (3) question (1)
Pull Request Labels
dependencies (52) github_actions (9)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 111,714 last-month
  • Total docker downloads: 9,129
  • Total dependent packages: 75
    (may contain duplicates)
  • Total dependent repositories: 185
    (may contain duplicates)
  • Total versions: 233
  • Total maintainers: 4
pypi.org: iminuit

Jupyter-friendly Python frontend for MINUIT2 in C++

  • Versions: 94
  • Dependent Packages: 60
  • Dependent Repositories: 137
  • Downloads: 111,714 Last month
  • Docker Downloads: 9,129
Rankings
Dependent packages count: 0.3%
Downloads: 1.0%
Dependent repos count: 1.3%
Docker downloads count: 1.6%
Average: 2.3%
Stargazers count: 4.0%
Forks count: 5.2%
Last synced: 4 months ago
proxy.golang.org: github.com/scikit-hep/iminuit
  • Versions: 79
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 3.0%
Stargazers count: 3.4%
Average: 6.7%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 4 months ago
conda-forge.org: iminuit

iminuit is designed from ground up to be fast, interactive and cython friendly. iminuit extract function signature very permissively starting from checking func_code down to last resort of parsing docstring (or you could tell iminuit to stop looking and take your answer). The interface is inspired heavily by PyMinuit and the status printout is inspired by ROOT Minuit. iminuit is mostly compatible with PyMinuit (with few exceptions). Existing PyMinuit code can be ported to iminuit by just changing the import statement.

  • Versions: 41
  • Dependent Packages: 12
  • Dependent Repositories: 24
Rankings
Dependent packages count: 5.1%
Dependent repos count: 7.4%
Average: 14.9%
Forks count: 22.2%
Stargazers count: 24.7%
Last synced: 4 months ago
anaconda.org: iminuit

iminuit is designed from ground up to be fast, interactive and cython friendly. iminuit extract function signature very permissively starting from checking func_code down to last resort of parsing docstring (or you could tell iminuit to stop looking and take your answer). The interface is inspired heavily by PyMinuit and the status printout is inspired by ROOT Minuit. iminuit is mostly compatible with PyMinuit (with few exceptions). Existing PyMinuit code can be ported to iminuit by just changing the import statement.

  • Versions: 19
  • Dependent Packages: 3
  • Dependent Repositories: 24
Rankings
Dependent packages count: 15.1%
Average: 29.4%
Dependent repos count: 30.4%
Forks count: 35.0%
Stargazers count: 37.1%
Last synced: 4 months ago

Dependencies

pyproject.toml pypi
  • numpy *
.github/workflows/coverage.yml actions
  • AndreMiras/coveralls-python-action develop composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • hendrikmuhs/ccache-action v1.2 composite
.github/workflows/docs.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • hendrikmuhs/ccache-action v1.2 composite
.github/workflows/release.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • docker/setup-qemu-action v2 composite
  • pypa/cibuildwheel v2.11.4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
  • softprops/action-gh-release v1 composite
.github/workflows/test.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • hendrikmuhs/ccache-action v1.2 composite