aspcore.correlation.cov_est_qis

aspcore.correlation.cov_est_qis(sample_cov, n)

Implements the quadratic-inverse shrinkage, the non-linear shrinkage from “Quadratic shrinkage for large covariance matrices” by Ledoit and Wolf.

Sample vectors in the sample covariance matrix should be i.i.d and zero mean.

Code adapted from https://github.com/pald22/covShrinkage by Patrick Ledoit It is here rewritten to use only numpy instead of pandas.

Parameters:
  • sample_cov (ndarray of shape (p,p)) – assumes the matrix is ensure to be symmetric positive semidefinite

  • n (int) – the sample size of the covariance matrix. If the sample mean was subtracted (if the variables were not zero mean), the sample size should be adjusted to n-1.

Returns:

cov_estimate

Return type:

ndarray of shape (p,p)