Skip to main content

Computes several covariance matrix estimators that ensure positive semi-definiteness (PSD).

Project description

psd_covariance package

A Python package for estimating positive semi-definite (PSD) covariance matrices. Includes methods for computing:

  • Sample covariance matrix;
  • Thresholding or correcting negative eigenvalues based on the work of Rousseeuw and Molenberghs (1993);
  • Linear Shrinkage and QIS Shrinkage of Ledoit & Wolf (2004, 2022);
  • The posterior mean (PM) and fixed-trace (FT) estimators from Boudt et al. (2025);
  • Fast cross-validation for regularization parameter tuning for PM and FT.

Installation

pip install psd-covariance

Quick Start

import numpy as np
from psd_covariance import utils, posterior_mean

np.random.seed(0)
X = np.random.multivariate_normal(
    mean=np.zeros(5),
    cov=0.8 ** np.abs(np.subtract.outer(np.arange(5), np.arange(5))),
    size=50
)

S = utils.sample_cov(X)

pm = posterior_mean.PosteriorMeanEstimator(fixed_trace=False)
Sigma_pm, _ = pm.fit(S, sigma=0.5)

print(Sigma_pm)

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

psd_covariance-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

psd_covariance-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file psd_covariance-0.1.0.tar.gz.

File metadata

  • Download URL: psd_covariance-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.1

File hashes

Hashes for psd_covariance-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c809457e4f7664d1265a77e8a2c6af1a7e2cc2f2c58bc0f990aaf63d9ee6d946
MD5 3024c8077ebd147ddd3904a8625048d5
BLAKE2b-256 e71acd56161ff017d40f6a6d00ea4d3058043ba4a6d175013e2c375ea4e62e56

See more details on using hashes here.

File details

Details for the file psd_covariance-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: psd_covariance-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.1

File hashes

Hashes for psd_covariance-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dab33e283d8092225b3989512852fc8f5e8e23d68045a2aafcf7a93bb35a129
MD5 22e99ebb8bb72f27d6155c0cea02d474
BLAKE2b-256 c14dd782d3ac432d6f260cde7547302cb91c54a25f9d50ebaa2e65b378e19171

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page