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
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c809457e4f7664d1265a77e8a2c6af1a7e2cc2f2c58bc0f990aaf63d9ee6d946
|
|
| MD5 |
3024c8077ebd147ddd3904a8625048d5
|
|
| BLAKE2b-256 |
e71acd56161ff017d40f6a6d00ea4d3058043ba4a6d175013e2c375ea4e62e56
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dab33e283d8092225b3989512852fc8f5e8e23d68045a2aafcf7a93bb35a129
|
|
| MD5 |
22e99ebb8bb72f27d6155c0cea02d474
|
|
| BLAKE2b-256 |
c14dd782d3ac432d6f260cde7547302cb91c54a25f9d50ebaa2e65b378e19171
|