https://github.com/microprediction/momentum
Running mean, variance, skew, and kurtosis
https://github.com/microprediction/momentum
kurtosis mean online-learning skewness variance
Last synced: 7 months ago
JSON representation
Running mean, variance, skew, and kurtosis
- Host: GitHub
- URL: https://github.com/microprediction/momentum
- Owner: microprediction
- License: mit
- Created: 2021-01-22T16:31:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-05T15:29:43.000Z (over 3 years ago)
- Last Synced: 2025-03-22T17:13:28.526Z (7 months ago)
- Topics: kurtosis, mean, online-learning, skewness, variance
- Language: Python
- Homepage: http://www.microprediction.org
- Size: 57.6 KB
- Stars: 11
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# momentum  
A trivial mini-package for computing the running univariate mean, variance, kurtosis and skew- No dependencies ... not even numpy.
- No classes ... unless you want them.
- State is a dict, for trivial serialization.
- Tested against scipy, creme, statisticsFor multivariate covariance updating, maybe see [precise](https://github.com/microprediction/precise).
### Install
pip install momentum
### Usage: running mean, var
from momentum import var_init, var_update
from pprint import pprint
m = var_init()
for x in [5,3,2.4,1.0,5.0]:
m = var_update(m,x)
pprint(m)
### Usage: running mean, var, kurtosis and skew
from momentum import kurtosis_init, kurtosis_update
m = kurtosis_init()
for x in [5,3,2.4,1.0,5.0]:
m = kurtosis_update(m,x)
pprint(m)
File an issue if you need more help using this.
### Usage: running recency-weighted mean, varfrom momentum import rvar_init, rvar_update
from pprint import pprint
m = rvar_init(rho=0.01,n=15)
for x in [5,3,2.4,1.0,5.0]:
m = rvar_update(m,x)
pprint(m)
This will switch from running variance to a weighted variance after 15 data points.