Package to perform fits in both CPUs and GPUs
Project description
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
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 Distribution
File details
Details for the file minkit-0.0.0.dev1.tar.gz
.
File metadata
- Download URL: minkit-0.0.0.dev1.tar.gz
- Upload date:
- Size: 88.6 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a8d02b6c24c32efe328934d0ecea84ee8b2bb244d6a5c4092fad20ddef0d884 |
|
MD5 | 692ad0fc69d68d00adb33da72f7ff6da |
|
BLAKE2b-256 | 750f9808bd90f19f4955cacf8bc0d76cbe427ff77749e7d666f34b200e172d8d |
File details
Details for the file minkit-0.0.0.dev1-py3-none-any.whl
.
File metadata
- Download URL: minkit-0.0.0.dev1-py3-none-any.whl
- Upload date:
- Size: 102.9 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3601d18177059aeb104468f6de76abaf66b2a6cb78b345ed717061d60a018bc6 |
|
MD5 | b14554293b1b6837792cf1f5cb33243d |
|
BLAKE2b-256 | 4742f9bc37d6a99cab121dd04e9524240049b7fd59df85cb1054e3ef9e09164d |