Numba-accelerated implementations of common probability distributions
Project description
numba-stats
We provide numba-accelerated implementations of statistical functions for common probability distributions
- Uniform
- (Truncated) Normal
- Log-normal
- Poisson
- (Truncated) Exponential
- Student's t
- Voigtian
- Crystal Ball
- Generalised double-sided Crystal Ball
- Tsallis-Hagedorn, a model for the minimum bias pT distribution
- Q-Gaussian
- Bernstein density (not normalised to unity, use this in extended likelihood fits)
with more to come. The speed gains are huge, up to a factor of 100 compared to scipy
. Benchmarks are included in the repository and are run by pytest
.
Usage
Each distribution is implemented in a submodule. Import the submodule that you need.
from numba_stats import norm
import numpy as np
x = np.linspace(-10, 10)
mu = 2
sigma = 3
dp = norm.pdf(x, mu, sigma)
p = norm.cdf(x, mu, sigma)
The functions are vectorised on the variate x
, but not on the shape parameters of the distribution. Ideally, the following functions are implemented for each distribution:
logpdf
pdf
cdf
ppf
cdf
and ppf
are missing for some distributions (e.g. voigt
), if there is currently no fast implementation available. logpdf
is only implemented if it is more efficient and accurate compared to computing log(dist.pdf(...))
.
Documentation
To get documentation, please use help()
in the Python interpreter.
Functions with equivalents in scipy.stats
follow the Scipy calling conventions exactly. These conventions are sometimes a bit unusual, for example, in case of the exponential, the log-normal or the uniform distribution. See the SciPy docs for details.
Contributions
You can help with adding more distributions, patches are very welcome. Implementing a probability distribution is easy. You need to write it in simple Python that numba
can understand. Special functions from scipy.special
can be used after some wrapping, see submodule numba_stats._special.py
how it is done.
numba-stats and numba-scipy
numba-scipy is the official package and repository for fast numba-accelerated scipy functions, are we reinventing the wheel?
Ideally, the functionality in this package should be in numba-scipy
and we hope that eventually this will be case. In this package, we don't offer overloads for scipy functions and classes like numba-scipy
does. This simplifies the implementation dramatically. numba-stats
is intended as a temporary solution until fast statistical functions are included in numba-scipy
. numba-stats
currently does not depend on numba-scipy
, only on numba
and scipy
.
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 numba-stats-1.1.0.tar.gz
.
File metadata
- Download URL: numba-stats-1.1.0.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/3.6.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0428c458ed0f88c80cfaeef858919945d2bae66b18cbc64fa61a36877d9fbb |
|
MD5 | 29790c115f9202719984f0f301f2bec7 |
|
BLAKE2b-256 | 5354d5d5d4cdff5fb2e291e7ddeb9b23ea2cbc94e9676f7cabba657d9d740208 |
File details
Details for the file numba_stats-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: numba_stats-1.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/3.6.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f34038c307817cad9fbb0bdffe271cde7e93b5c74c3562d28f8ccddf26aacd85 |
|
MD5 | 5a3f67e52950bd0edf2267d7707c68c1 |
|
BLAKE2b-256 | 64979e1ea0c75732a2c8f9b599c89186a95bcf8f2afbf439a06fdf58d96d1b73 |