Skip to main content

Package to perform fits in both CPUs and GPUs

Project description

https://img.shields.io/travis/mramospe/minkit.svg https://img.shields.io/badge/documentation-link-blue.svg https://codecov.io/gh/mramospe/minkit/branch/master/graph/badge.svg

This package provides tools to fit probability density functions (PDFs) to both unbinned and binned data, using different minimizers (like Minuit). The MinKit package appears as an alternative to existing minimization packages, like RooFit. The idea is to provide a friendly pure python API to do minimization and calculations with PDFs. It has support for both CPU and GPU backends, being very easy for the user to change from one to the other. PDFs are implemented in C++, OpenCL and CUDA, allowing a fast evaluation of the functions.

The package is built on top of the numpy and iminuit packages. The interface with CUDA and OpenCL is handled using reikna, which is itself an API for PyCUDA and PyOpenCL.

Basic example

Classes meant for the user are imported directly from the main module

import minkit

x = minkit.Parameter('x', bounds=(-10, +10))
c = minkit.Parameter('c', 0.)
s = minkit.Parameter('s', 1.)
g = minkit.Gaussian('Gaussian', x, c, s)

data = g.generate(10000)

These lines define the parameters used by a Gaussian function, and a data set is generated following this distribution. The sample can be easily fitted calling:

with minkit.unbinned_minimizer('uml', g, data) as minimizer:
   r = minimizer.migrad()

In this case minimizer is a Minuit instance, since by default Minuit is used to do the minimization. The string uml specifies the type of figure to minimize (FCN), unbinned-maximum likelihood, in this case.

The compilation of C++ sources is completely system dependent (Linux, MacOS, Windows), and it also depends on the way python has been installed. The PDFs in this package need the C++ standard from 2011. Depending on the system, functions might need to be compiled with extra flags that are not used by default in distutils. If you get errors of the type:

relocation R_X86_64_PC32 against undefined symbol

suggesting to use -fPIC option (when the system is using gcc to compile C code) or

error: ‘erf’ is not a member of ‘std’

more likely it is needed to specify the flags to use. In order to do so, simply execute your script setting the value of the environmental variable CFLAGS accordingly:

CFLAGS="-fPIC -std=c++11" python script.py

Fast installation:

This package is available on PyPi, so simply type

pip install minkit

to install the package in your current python environment. To use the latest development version, clone the repository and install with pip:

git clone https://github.com/mramospe/minkit.git
pip install minkit

In order to profit from certain features of the package, like numerical integration, it is necessary that the system has the GSL libraries visible to the compiler. To install them on Linux, you can simply run

sudo apt-get install libgsl-dev

Depending on the system, you might need to set also the necessary environment variables specifying the path to the include and libraries directory, like

export CFLAGS="$CFLAGS -I/usr/include -L/usr/lib/x86_64-linux-gnu"

Project details


Download files

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

Source Distribution

minkit-0.0.0.dev0.tar.gz (83.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minkit-0.0.0.dev0-py3-none-any.whl (94.4 kB view details)

Uploaded Python 3

File details

Details for the file minkit-0.0.0.dev0.tar.gz.

File metadata

  • Download URL: minkit-0.0.0.dev0.tar.gz
  • Upload date:
  • Size: 83.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for minkit-0.0.0.dev0.tar.gz
Algorithm Hash digest
SHA256 304fdc23e6f2a176a8e30ed6d952fd0f8ce34375a87e897f4bdd844b2ddee57f
MD5 6f1760b83271f83367d33c5b6d5aed80
BLAKE2b-256 c4ce5874a9c392508989ad1f7844a153c09208cc70c20524630ffa50a9955893

See more details on using hashes here.

File details

Details for the file minkit-0.0.0.dev0-py3-none-any.whl.

File metadata

  • Download URL: minkit-0.0.0.dev0-py3-none-any.whl
  • Upload date:
  • Size: 94.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for minkit-0.0.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 ace3e219386eb5afe290d53292a1a061fcbc12389517786693e4e00a77874792
MD5 10c093c51b2af093d2b7a00d2a3f0f23
BLAKE2b-256 d66df410b266ffb66da6e7b54ae756fd8ff9ce43a944240e16d9004ffe3e4082

See more details on using hashes here.

Supported by

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