qis.matrix_regularization

qis.matrix_regularization(covar, cut=1e-05)[source]

eigenvalue clipping of a symmetric matrix: eigenvalues at or below cut are set to zero.

Rebuilds Q diag(nu_j 1{nu_j > cut}) Q' from np.linalg.eigh, which reads only the lower triangle. With cut=0 this is the Frobenius-nearest positive semi-definite matrix. The result is singular whenever an eigenvalue was clipped, and clipping raises the diagonal, so renormalise a clipped correlation matrix with qis.covar_to_corr.

Parameters:
  • covar (ndarray) – symmetric matrix, shape (n, n)

  • cut (float) – absolute eigenvalue threshold, in the units of covar. The default 1e-5 is small for an annualised covariance but comparable to daily variances

Returns:

the clipped matrix, shape (n, n)

Return type:

ndarray