Skip to main content

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
  • 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.

Documentation (or lack of)

Because of limited manpower, this project is poorly documented. The documentation is basically the source code. pydoc numba_stats does not really work at the moment, because Numba does not show the docstring of the wrapped function but the docstring of the wrapping function. The plan is to fix this (either in Numba or locally). The calling conventions for those functions which have a scipy.stats equivalent, are identical to those in SciPy. 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.

Plans for version 1.0

Version v1.0 will introduce breaking changes to the API. Users are recommended to update their code.

# before v0.8
from numba_stats import norm_pdf
from numba_stats.stats import norm_cdf

dp = norm_pdf(1, 2, 3)
p = norm_cdf(1, 2, 3)

# recommended since v0.8
from numba_stats import norm

dp = norm.pdf(1, 2, 3)
p = norm.cdf(1, 2, 3)

This is nicer code, but more importantly, this is necessary to battle the increasing startup times of numba-stats. Now you only pay the compilation cost for the distribution that you actually import. The stats submodule will be removed. To keep old code running, please pin your numba_stats to version <1.

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


Download files

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

Source Distribution

numba-stats-0.9.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

numba_stats-0.9.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file numba-stats-0.9.0.tar.gz.

File metadata

  • Download URL: numba-stats-0.9.0.tar.gz
  • Upload date:
  • Size: 15.2 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

Hashes for numba-stats-0.9.0.tar.gz
Algorithm Hash digest
SHA256 f9df0ca2c0de61beeee952c75908bb8d7269b24df3bcfb4ed38653406bb9d358
MD5 8783ac8c9cf85156729770c9eb9dafe5
BLAKE2b-256 4af1b483ea607db0f62d46c17ba09df2c9ec246c66ba045a8902532e36cd762d

See more details on using hashes here.

File details

Details for the file numba_stats-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: numba_stats-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 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

Hashes for numba_stats-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de5a2e9753d1a70003d6dcc12d1cd172bd535bfb6eb8f8513befc2c0d50e0b9f
MD5 baf76ea487601be5115a84b045a4dd3b
BLAKE2b-256 66ea1ff943f91e4c80746b10196c125388a20cc281dc0855b507fec547be0a3f

See more details on using hashes here.

Supported by

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