Find the nearest covariance matrix that is postive (semi-) definite
This leaves the diagonal, i.e. the variance, unchanged
Parameters: | cov : ndarray, (k,k)
method : string
threshold : float
nfact : int or float
return_all : bool
|
---|---|
Returns: | cov_ : ndarray
corr_ : ndarray, (optional)
std_ : ndarray, (optional)
|
See also
Notes
This converts the covariance matrix to a correlation matrix. Then, finds the nearest correlation matrix that is positive semidefinite and converts it back to a covariance matrix using the initial standard deviation.
The smallest eigenvalue of the intermediate correlation matrix is approximately equal to the threshold. If the threshold=0, then the smallest eigenvalue of the correlation matrix might be negative, but zero within a numerical error, for example in the range of -1e-16.
Assumes input covariance matrix is symmetric.