Online statistics for Numpy arrays.
Project description
numpy-onlinestats
This is a Python package for element-wise streaming statistics of Numpy arrays, meaning that arrays can be added one-by-one. This is much more memory-efficient than first collecting all arrays before calculating statstics. One major usecase is Bayesian modeling, where the posterior distribution is often intractable and can only be approximated via sampling. This concerns both MCMC and variational inference meethods. MCMC is inherently sampling-based, while variational inference methods can have derived quantities or structured posteriors that do not admit closed-form expressions for properties of their distribution.
numpy-onlinestats approximates quantiles and cumulative distribution functions using the t-digest algorithm (in particular, it uses this implementation) and calculates exact moments using a numerically stable algorithm.
Requirements
- Python 3.10 or newer
- A C++20 compatible compiler (developed with GCC 13 using
-std=c++20
)
Sample code
import numpy as np
import numpy_onlinestats as npo
stats = npo.NpOnlineStats(np.random.uniform((5, 3, 7)))
for i in range(100):
stats.add(np.random.uniform((5, 3, 7)))
stats.quantile(0.25)
stats.mean()
stats.var()
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 Distributions
File details
Details for the file numpy-onlinestats-0.1.0.tar.gz
.
File metadata
- Download URL: numpy-onlinestats-0.1.0.tar.gz
- Upload date:
- Size: 662.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4412eabbc9f9fe0ede8b8423fbf397f4a24bb9e59836b7b4e0445f08ac9a7ae3 |
|
MD5 | 5cdd3fba00ca4675d3eed2f6a45ecb5f |
|
BLAKE2b-256 | bc90303c63d6a480ee764033492c2d2c39c684fa78ea1155b7813d1d9a7de01a |
File details
Details for the file numpy_onlinestats-0.1.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: numpy_onlinestats-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 676.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd3d1affb2a502a098e09151de3db6b6e1d52f6d56616d525e3ff538840168dc |
|
MD5 | 1bf4f112bf65674a229e55333bc81a6c |
|
BLAKE2b-256 | 58982c49da30ba9dd6aa33ad82725b7bcbacd55a2c43a938b8350ead7985346e |
File details
Details for the file numpy_onlinestats-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: numpy_onlinestats-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 221.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4369872a2c50564afc648ef8fc2471a699b5218c19ed56eb72d5f1c66fba5a4 |
|
MD5 | 15e597159c1dc445d8dd6ae1424c7653 |
|
BLAKE2b-256 | a668a933a0fb44eebbca04bdf5ce476ad3deb3e215c1efa730da604e55a23e50 |
File details
Details for the file numpy_onlinestats-0.1.0-cp311-cp311-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: numpy_onlinestats-0.1.0-cp311-cp311-macosx_10_15_x86_64.whl
- Upload date:
- Size: 409.5 kB
- Tags: CPython 3.11, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92da04610b881157a1112a51dee425d7e990cccb69d8265f22350ba9323106de |
|
MD5 | a4a17236ac5b6ef835615a15c9ac5d2c |
|
BLAKE2b-256 | f072b4507e6b3e35a26b9ccb62663c4d01d0a16081b5aaa845654082331a86d2 |
File details
Details for the file numpy_onlinestats-0.1.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: numpy_onlinestats-0.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 676.7 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84c70a8289c38525f26bc7f282d060630a4246a1f82779d81fd3df52946301b6 |
|
MD5 | 6e24c3e5cb26ec8277cfbe88afc0d948 |
|
BLAKE2b-256 | c80c458f19ddaffa1d4b621d730486ee193094ccfb43434031b011e01b9a42ca |
File details
Details for the file numpy_onlinestats-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: numpy_onlinestats-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 221.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 954df063eabb95c9e26955ce8f6b8c2f0b3cdd186c3d3eb7e5093cd5693ec0dc |
|
MD5 | 15ae0ecdf1e5895ccc8977c5d6a67150 |
|
BLAKE2b-256 | d9c44dcd4d6e4a29be9a7e38f8946ab58e53f8cb786b52ab120fe50f96765176 |
File details
Details for the file numpy_onlinestats-0.1.0-cp310-cp310-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: numpy_onlinestats-0.1.0-cp310-cp310-macosx_10_15_x86_64.whl
- Upload date:
- Size: 409.7 kB
- Tags: CPython 3.10, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc8be99d5351fceb84341c844dd351329969ac35897f8189abeb4e1a2295b30a |
|
MD5 | af89a66e0f9cfd1f7307c269e4faf800 |
|
BLAKE2b-256 | 938ad1bc051f2be8874e9ded2f88b8db86f00193b83e917a73b9729dd0d8b0c0 |