An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# momentum ![tests](https://github.com/microprediction/momentum/workflows/tests/badge.svg) ![deploy](https://github.com/microprediction/momentum/workflows/deploy/badge.svg)
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, statistics

For 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, var

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