Online stats in python, based in generators with send
Project description
Generators Based Online Statistics
This package implement online statistics written using python generators, with the only depencency of numpy.
It can calculate basic stats in an online manner with good stability.
The Repo focus in simplicity and compousability, reliying 100% on python Generators.
By desingn window operations increase in window size till the desired size instead of returning Nan in the initialization period as pd.rolling does.
install
poetry add onstats
pip install onstats
How to use:
Import the window / rolling statistic you want to compute and send the values to it:
>>> from onstats.stats import ma # moving average
>>> from onstats.util import send
>>> gma = ma(2) # with window 2
>>> gma.send(3)
3
>>> gma.send(5)
4
>>> gma.send(5)
5
If w = 0 the window is infinitelly large , we will compute the normal average.
You can also feed all the iterator directly:
>>> gma = ma(2) # with window 2
>>> send(gma, [3,5,5])
5
Or as an iterator
>>> gma = ma(2) # with window 2
>>> for d in isend(gma, [3,5,5]):
>>> print(d)
3
4
5
You can also pass 2d np.arrays:
>>> gma = ma(2) # with window 2
>>> for d in isend(gma, np.array([[0,0],[1,2],[1,4]])):
>>> print(d)
[0,0]
[0.5,1]
[1,3]
Supported Stats:
rolling | window | infinite | Ddoff | Description |
---|---|---|---|---|
ma | ✅ | ✅ | Moving Average | |
ema | ✅ | Exponential Moving Average | ||
var | ✅ | ✅ | ✅ | Variance |
ath | ✅ | All Time High | ||
wsum | ✅ | ✅ | Windowed Sum | |
cov_xy | ✅ | ✅ | Covariance | |
corr_xy | ✅ | ✅ | Correlation | |
auto_corr | ✅ | ✅ | Auto Correlation |
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
Built Distribution
File details
Details for the file onstats-0.9.4.tar.gz
.
File metadata
- Download URL: onstats-0.9.4.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-9-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8efe95b7f437b637de3d774ac730a9438f5fd28d0e4fdfdcfbac087587a17348
|
|
MD5 |
eb2555068c8790040999d778b5282c06
|
|
BLAKE2b-256 |
b3821db1ebc30eeb24ce072e688b0895c912cabd0f430c2e24705b199aa77727
|
File details
Details for the file onstats-0.9.4-py3-none-any.whl
.
File metadata
- Download URL: onstats-0.9.4-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-9-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
59a6e08d2efcce7c38c8671335cdff04b8d9d9e4fcc16a24623d0b8f35428f5b
|
|
MD5 |
9966db5acf040b77c8da7365bdc8e754
|
|
BLAKE2b-256 |
8ec989bdc5d32381ce2e2eaef3aa4204533f19d4bac2c146eecbe072acd76435
|