Skip to main content

Online covariance and precision estimation

Project description

precise

A collection of autonomous online (incremental) covariance matrix estimators.

Install

pip install precise 

Examples

See /examples_basic_usage

Explanation

You use state updaters, then functions of the state.

State updates

All updaters take a prior state and return a posterior state (dict). An empty dict is passed to initialize.

Example:

from precise.synthetic.generate import create_correlated_dataset
from precise.covariance.empirical import emp_pcov

if __name__=='__main__':
    xs = create_correlated_dataset(n=500)
    s = {}
    for x in xs:
        s = emp_pcov(s=s, x=x)
    pprint(s['scov'])

Naming hints:

Shorthand Intent
scov Sample covariance
pcov Population covariance
spre Sample precision
ppre Population precision

Method hints:

Shorthand Meaning
emp Empirical
ema Exponential weighted moving average
lz Le-Zhong variable-by-variable updating
lw (inspired by) Ledoit-Wolf

Some, such as OAS, don't need their own state tracking. See examples.

State functions & mutations

Three types of utilities exist

  1. The covariance/statefunctions are illustrated by the example running_oas_covariance.
  2. State covariatnce/statemutations do things like ensuring both covariance and precision matrices exist in the state. Or for instance: s = both_cov(s) ensures both sample and population covariances are present.
  3. Miscellaneous /covariance/matrixfunctions functions act directly on matrices.

Updater hyper-parameters

The intent is that methods are parameter free. However some not-quite autonomous methods admit just one additional scalar parameter r and that can make the creation of fully autonomous methods simpler, akin to the tuning of skaters explained here in the timemachines package.

Miscellaneous

  • Care to cite, some ideas here
  • If you just want univariate, and don't want numpy as a dependency, there is momentum.

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

precise-0.1.0.tar.gz (14.7 kB view hashes)

Uploaded Source

Built Distribution

precise-0.1.0-py3-none-any.whl (18.2 kB view hashes)

Uploaded Python 3

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