Skip to main content

precise

Online covariance, correlation and precision matrix computations

Install

pip install precise 

Example

from precise.covariance.util import create_correlated_dataset
from precise.covariance.onlineempirical import online_empirical_cov
import numpy as np
from pprint import pprint

data = create_correlated_dataset(10000, (2.2, 4.4, 1.5),
                                 np.array([[0.2, 0.5, 0.7], [0.3, 0.2, 0.2], [0.5, 0.3, 0.1]]), (1, 5, 3))
s = online_empirical_cov(n_dim=data.shape[1])
for observation in data:
    s = online_empirical_cov(s=s, y=observation)
pprint(s)

This will return the running state, which includes the mean and cov

{'count': 10000,
 'cov': array([[0.38549265, 1.55198303, 0.73809891],
       [1.55198303, 9.41813338, 6.20756741],
       [0.73809891, 6.20756741, 4.79042088]]),
 'identity': array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]]),
 'mean': array([2.19919374, 4.42189785, 1.52406171]),
 'n_dim': 3,
 'ones': array([1., 1., 1.]),
 'shape': (3, 3)}

To covert to corrcoef,

  from precision.covariance.util import cov_to_corrcoef
  pprint( cov_to_corrcoef(s['cov']) )

returns:

  array([[1.        , 0.81749783, 0.55345955],
   [0.81749783, 1.        , 0.92689045],
   [0.55345955, 0.92689045, 1.        ]])

See also

If you only need univariate, there is a really minimalise package momentum which avoids use of numpy.

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.0.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

precise-0.0.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file precise-0.0.2.tar.gz.

File metadata

  • Download URL: precise-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for precise-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4dd4aa018192dea1a1db87b37c9ea2461bd78a37d65ad59083278ec81deb0e4c
MD5 9e687a4eb322b2e35933a300a060d9a5
BLAKE2b-256 faf9500ad0c3e67d3aadc39c071cd04629a951bbc678ed49855f812a71dbf73f

See more details on using hashes here.

File details

Details for the file precise-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: precise-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for precise-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d5e9f29c9bc94e7cab9364b59f83dbfe0e085c60c5a515c9e0902e4c7dc85dc
MD5 4eb16e2ac619dee8cf4c5524c89c16e5
BLAKE2b-256 cba9a7851ca025287c451d4eacc9f429532a39706b0c52096204cba76b720b12

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.0

2 files

1.0.0

2 files

0.16.7

2 files

0.16.3

2 files

0.16.2

2 files

0.16.1

2 files

0.15.0

2 files

0.14.1

2 files

0.14.0

2 files

0.13.5

2 files

0.13.4

2 files

0.13.2

2 files

0.13.0

2 files

0.12.8

2 files

0.12.7

2 files

0.12.5

2 files

0.12.4

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.11.17

2 files

0.11.15

2 files

0.11.14

2 files

0.11.13

2 files

0.11.12

2 files

0.11.10

2 files

0.11.9

2 files

0.11.8

2 files

0.11.7

2 files

0.10.33

2 files

0.10.29

2 files

0.10.28

2 files

0.10.21

2 files

0.10.14

2 files

0.10.4

2 files

0.10.3

2 files

0.10.1

2 files

0.10.0

2 files

0.9.5

2 files

0.9.1

2 files

0.8.7

2 files

0.8.1

2 files

0.8.0

2 files

0.7.5

2 files

0.7.3

2 files

0.7.1

2 files

0.7.0

2 files

0.6.10

2 files

0.6.1

2 files

0.5.21

2 files

0.5.16

2 files

0.5.13

2 files

0.5.12

2 files

0.5.11

2 files

0.5.10

2 files

0.5.9

2 files

0.5.7

2 files

0.5.5

2 files

0.4.18

2 files

0.4.0

2 files

0.3.14

2 files

0.3.13

2 files

0.3.1

2 files

0.1.0

2 files

This release

0.0.2 This release

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page